This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2013-01-10 13:22:32

hondarider8924
New Scratcher
Registered: 2013-01-08
Posts: 1

recording the coordinates of the mouse once clicked

i want to record the mouses x and y values once it is the right button on the mouse is clicked. any ideas?

Offline

 

#2 2013-01-10 14:57:53

technoguyx
Scratcher
Registered: 2008-10-18
Posts: 1000+

Re: recording the coordinates of the mouse once clicked

Scratch can't distinguish between the left and right mouse buttons, sadly  hmm  However it is possible to record the position of the mouse using the "mouse x" and "mouse y" blocks in "Sensing":

when Sprite1 clicked
set [x v] to (mouse x)
set [y v] to (mouse y)


http://getgnulinux.org/links/en/linuxliberated_4_78x116.png

Offline

 

#3 2013-01-10 15:31:37

chimoo5
New Scratcher
Registered: 2013-01-08
Posts: 18

Re: recording the coordinates of the mouse once clicked

I have an idea but it ask the user whether it is left or right.

when gf clicked
forever
if <mouse down?>
ask [Right or Left?] and wait
set [x v] to (mouse x)
set [y v] to (mouse y)
if <<(answer) = [right]> or <(answer) = [r]>>
say [Code for Right Click] for (2) secs
else
end
The downside is for every time you click you get a question.
This can be changed to a specific call like pressing r then click

when [r v] key pressed
if <mouse down?>
set [x v] to (mouse x)
set [y v] to (mouse y)
say [Code for Right Click] for (2) secs
end
If you need help to tweak this more to your needs let me know I'll look into it.

Offline

 

#4 2013-01-10 16:34:09

technoguyx
Scratcher
Registered: 2008-10-18
Posts: 1000+

Re: recording the coordinates of the mouse once clicked

Or you could simply check whether the user is pressing another key - similarly to how one would Ctrl or Shift-click something.

when gf clicked
forever
  if <mouse down?>
    if <key [z v] pressed?> //"right click" - actually, Z-click
      set [x v] to (mouse x)
      set [y v] to (mouse y)
    else //normal, left click
      say [do stuff]
    end
  end
end


http://getgnulinux.org/links/en/linuxliberated_4_78x116.png

Offline

 

Board footer