Polling the mouse state

Scott Rossi scott at tactilemedia.com
Sat Feb 23 15:49:01 CST 2002


Recently, Ken Norris (dialup) wrote:

>> If you have a specific need that seems to require "repeat while the mouse is
>> down," post it and we'll see if we can figure a way around it.
>> 
> ----------
> Not exactly, but, how about this:
> 
> on mousestilldown
> put max(81,min(557,the mouseh)) into x
> put max(167,min(287,the mousev)) into y
> set the loc of me to x,y
> end mousestilldown
> 
> ...This is an oval (made round) button with the hilite set to true. It 'sees
> through' a black-filled rectangular box, like a spyglass, so the user can
> see portions of a color image underneath. It stays within the borders of the
> box as you drag it around. The user is looking for an object.
> 
> When they find what they believe is the correct object, release the mouse
> button

If I understand your request, this is one way you could do the above.  Make
3 small graphics named box 1, box 2 and box 3 within the region you define.
Then place the following script in your oval:

on mouseDown
  set the uAllowMove of me to true
end mouseDown

on mouseMove x,y
  if not the uAllowMove of me then exit mouseMove
  set the loc of me to (max(81,min(557,x))),(max(167,min(287,y)))
end mouseMove

on mouseUp
  set the uAllowMove of me to empty
  put "box1,box2,box3" into bList
  repeat for each item B in bList
    if within(me,loc of grc B) then
      put "You found box" && B
      exit repeat
    else put empty
  end repeat
end mouseUp

on mouseRelease
  mouseUp
end mouseRelease

-----

This should display the name (in the message box) of any box graphic that
falls within the oval when the mouse is released.

BTW, did you look at the drag example I posted a few days ago?

  http://www.tactilemedia.com/download/drag_sample.mc

You might find this useful.

Regards,

Scott Rossi
Creative Director

Tactile Media, Multimedia & Design
Email: scott at tactilemedia.com
Web: www.tactilemedia.com




More information about the use-livecode mailing list