Constraining 'grab'
Jacqueline Landman Gay
jacque at hyperactivesw.com
Wed Mar 6 06:27:01 EST 2002
On Wednesday, March 6, 2002, at 05:07 AM, Ken Norris (dialup)" <pixelbird@
interisland.net wrote:
> You're saying that if I drag outside the stack, then the thing I'm over,
> like a menu item, gets the mouseUp message when I release, no matter what
> object script _initiated_ the mouseUp message, unless I take the extra
> step
> of deliberately killing it? I dunno...that makes no sense to me. Why would
> the mouseUp message get passed to any other object than the one that
> initiated it (unless it was written that way on purpose), as long as the
> mouse is still down in the dragging condition when you get there?
No, that's not what's happening. In HyperCard, a mouseUp message is sent
to the original object that received the mousedown, always and without
exception. In MetaCard, if the user releases the mouse outside of the
original object, a mouseRelease message is sent to the object rather than
a mouseUp. MouseUp is only sent if the release happens inside the original
object.
This is very handy. If the user releases the mouse inside the original
control, scripts can treat it just as HyperCard did with a mouseUp handler.
But if the user releases the mouse outside of the control, the
mouseRelease message is a good way to clean up anything that may have
changed and exit gracefully. In HC, to do the same thing, you'd have to
poll the mouse location on "mouseup" to see whether the user actually
finished clicking the button or not. In MC, you just use the mouseRelease
message, because if you are getting a mouseUp, you know for sure that the
button was clicked and if you are getting a mouseRelease, you know for
sure it wasn't.
One common reason for needing to trap mouseRelease is because users change
their minds. They will mouse down on a button, realize they don't really
want to click it, and slide the mouse off the button before releasing. If
the button script has a mousedown handler that changes the environment in
any way, then trapping mouserelease will allow you to set everything back
the way it was, even though a full mouseclick never happened.
--
Jacqueline Landman Gay | jacque at hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
More information about the use-livecode
mailing list