object beneath mouseLoc?
Dick Kriesel
dick.kriesel at mail.com
Tue Jul 5 03:46:55 EDT 2011
On Jul 4, 2011, at 5:55 PM, Nicolas Cueto wrote:
>> Didn't work well, though. The target object's id got returned, but the mouseMove wouldn't exit.
Nicolas,
The mouseMove in that old example was just to demonstrate how to invoke the core code, and to show that the result of executing it changes as you move the cursor over different objects.
Reworking the old example for your situation gives you one function to insert into your script. Then invoke it whenever your script needs to know the object under the mouse. There's no resource wasted for polling, so this technique can handle more screen objects than you'd probably ever want to use. There's no wrong result when the pointer's outside an object but inside its rect, as happens near the corners of a rounded rect button.
Here's the function to put into the script you're developing:
function mouseObject
return value( "mouseObject()", long id of button "mouseObject")
end mouseObject
Create button "mouseObject" and give it this script:
local sMouseObject
function mouseObject
if line 1 of the frontscripts is not long id of me then
put empty into sMouseObject
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
Does that work for you?
-- Dick
More information about the use-livecode
mailing list