Get the name of intersecting button
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Get the name of intersecting button
I am wondering how to get the name of the button that is being intersected when doing a drag operation.... so for instance... You have 5 buttons in a group and each button has a grab command in the mouseDown handler, how can I determine which button the dragged button is colliding with? I understand using the intersect command works when naming a particular button, but when there are multiple buttons on a screen, it seems labor intensive to list all possible intersect scenarios. Thanks for the help...
Re: Get the name of intersecting button
well I am getting good at answering my own questions....

Code: Select all
global vOldLoc
on mouseUp
repeat with x=1 to the number of btns on this cd
if the intersect(me,btn x) then
put the short name of btn x into vName
put the loc of btn x into vLoc
move me to vLoc in 10 ticks
exit repeat
else
end if
end repeat
move btn vName to vOldLoc in 10 ticks
end mouseUp
on mouseDown
grab me
set the layer of me to top
put the loc of me into vOldLoc
end mouseDown
on mouseStillDown
set the ink of me to srcOrReverse
end mouseStillDown
Re: Get the name of intersecting button
What Kenny said!
Hint: "mosuestilldown" is a bit CPU intensive and since you do not set the INK back somewhere,
it might be a good idea to only set the INK once on mousedown:
Best
Klaus

Hint: "mosuestilldown" is a bit CPU intensive and since you do not set the INK back somewhere,
it might be a good idea to only set the INK once on mousedown:
Code: Select all
global vOldLoc
on mouseUp
repeat with x=1 to the number of btns on this cd
if the intersect(me,btn x) then
put the short name of btn x into vName
put the loc of btn x into vLoc
move me to vLoc in 10 ticks
exit repeat
## Really no empty ELSE case neccesary 8-)
end if
end repeat
move btn vName to vOldLoc in 10 ticks
end mouseUp
on mouseDown
grab me
set the ink of me to srcOrReverse
set the layer of me to top
put the loc of me into vOldLoc
end mouseDown
## Look ma, no "mousestilldown" :-)
Klaus