Mouse messages while down
Dick Kriesel
dick.kriesel at mail.com
Mon Mar 19 06:38:14 EDT 2007
On 3/18/07 12:12 AM, "Sarah Reichelt" <sarah.reichelt at gmail.com> wrote:
> I'm now doing the politically correct mouseMove instead of using
> repeat while mouse is down. But it still leaves me having to check the
> location all the time to see whether it is inside one of my 400
> buttons. It seems that the mouseControl should be able to report where
> the mouse is without me having to check it manually. But mouseControl
> gets stuck when you click down and never changes until the mouse comes
> up again.
Here's another technique for identifying the object at the mouseLoc. This
technique is different because it works with no repeat loop, no checking the
visible or the rect of any object, no formulas based on the mouseLoc, and no
reference to the mouseControl.
Create a button named "mouseObject" with the following script:
-- <script>
local sMouseObject
on mouseObject
if line 1 of the frontscripts is not long id of me then
insert script of me into front
lock screen
click at the mouseloc
unlock screen
remove script of me from front
return sMouseObject
end if
end mouseObject
on mousedown
end mousedown
on mouseUp
put long id of the target into sMouseObject
end mouseUp
-- <script/>
Then to test it, put the following handler into the stack script:
-- <script>
on mouseMove
call "mouseObject" of button "mouseObject" of me
put the result
end mouseMove
-- <script/>
The technique passed my tests. Does it work for you?
-- Dick
More information about the use-livecode
mailing list