MouseUp event isn't being triggered
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
MouseUp event isn't being triggered
Hello everyone,
This seems a trifle strange.
My user interface requires some large tiles down the left of the screen, which trigger the display of various panels of information to the right. The tiles are comprised of some graphics with a transparent button overlaid to capture mouse events. Upon mouseEnter, mouseLeave and mouseDown, I modify the objects beneath to provide visual feedback of interaction. I track the state of the button using a repeat while the mouse is down loop in the mouseDown handler, changing the tile's state should the user click, hold and move outside of the tile's rectangle.
To keep things simple, each transparent button has a behavior in a hidden button and working out which tile was interacted with is done by evaluating its name. All tiles are kept in a scrolling group.
The weird thing is that mouseUp is not always triggered. I have found that a simple click fails to fire mouseUp. A more purposeful click normally does.
For the time being, I've modified the mouseDown handler to determine the state of the tile once the button is released and execute what I'd otherwise put in mouseUp but my code would be more clear if I could use mouseUp.
Thanks,
Steve
This seems a trifle strange.
My user interface requires some large tiles down the left of the screen, which trigger the display of various panels of information to the right. The tiles are comprised of some graphics with a transparent button overlaid to capture mouse events. Upon mouseEnter, mouseLeave and mouseDown, I modify the objects beneath to provide visual feedback of interaction. I track the state of the button using a repeat while the mouse is down loop in the mouseDown handler, changing the tile's state should the user click, hold and move outside of the tile's rectangle.
To keep things simple, each transparent button has a behavior in a hidden button and working out which tile was interacted with is done by evaluating its name. All tiles are kept in a scrolling group.
The weird thing is that mouseUp is not always triggered. I have found that a simple click fails to fire mouseUp. A more purposeful click normally does.
For the time being, I've modified the mouseDown handler to determine the state of the tile once the button is released and execute what I'd otherwise put in mouseUp but my code would be more clear if I could use mouseUp.
Thanks,
Steve
-
- VIP Livecode Opensource Backer
- Posts: 9578
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: MouseUp event isn't being triggered
Hi.
If what you describe is true, then maybe you need a new mouse.
Not sure if I am kidding or not. An action like a click on a control should not act that way at all. This begs the issue whether putting a single handler in the card script is simpler, eliminating all those behaviors, transparent buttons, etc. The use of the "target" will tell LC which graphic you clicked on.
Have you looked at the message watcher while clicking? Do you alway get a "mouseUp" message? You may want to suppress much of what that gadget shows in order to filter out most of the uninteresting messages that come along.
Craig
If what you describe is true, then maybe you need a new mouse.
Not sure if I am kidding or not. An action like a click on a control should not act that way at all. This begs the issue whether putting a single handler in the card script is simpler, eliminating all those behaviors, transparent buttons, etc. The use of the "target" will tell LC which graphic you clicked on.
Have you looked at the message watcher while clicking? Do you alway get a "mouseUp" message? You may want to suppress much of what that gadget shows in order to filter out most of the uninteresting messages that come along.
Craig
Re: MouseUp event isn't being triggered
Hi Craig,
Thanks for this.
I've tried with both my mouse and trackpad and, in the Message Watcher, I can see all of the mouse events fire except for MouseUp, on the occasions I mention. Seems strange that I can have a mouseDown but no associated mouseUp.
What I have now found is that if the mouseUp handler puts something into the message box, to show it has been received, it always fires.
Thanks,
Steve
Thanks for this.
I've tried with both my mouse and trackpad and, in the Message Watcher, I can see all of the mouse events fire except for MouseUp, on the occasions I mention. Seems strange that I can have a mouseDown but no associated mouseUp.
What I have now found is that if the mouseUp handler puts something into the message box, to show it has been received, it always fires.
Thanks,
Steve
-
- VIP Livecode Opensource Backer
- Posts: 9578
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: MouseUp event isn't being triggered
Hmmm.
Have you run a search for "mouseUp" throughout your stack? Are you sure it is not trapped somewhere up the message hierarchy?
If you are getting something in msg, it sounds like you have a handler somewhere that puts, as you say, "something" into msg explicitly.
Craig
Have you run a search for "mouseUp" throughout your stack? Are you sure it is not trapped somewhere up the message hierarchy?
If you are getting something in msg, it sounds like you have a handler somewhere that puts, as you say, "something" into msg explicitly.
Craig
Re: MouseUp event isn't being triggered
It's a strange one. There are no mouseUps in the buttons themselves, nor in the group they're a part of, nor at the card and stack levels.
It's a fairly simple stack, really.
Steve
It's a fairly simple stack, really.
Steve
-
- VIP Livecode Opensource Backer
- Posts: 7214
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: MouseUp event isn't being triggered
Does the code that modifies the button states contain a repeat loop? MouseUp messages can get lost in those if you don't yield time to the engine.
Even if there is no repeat loop, putting something in the message box also gives time to the engine. You might add a "wait 0 with messages" in the behavior to see if that helps.
Even if there is no repeat loop, putting something in the message box also gives time to the engine. You might add a "wait 0 with messages" in the behavior to see if that helps.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: MouseUp event isn't being triggered
Thanks Jacque.
Yes, the mouseDown handler contains a loop, which it uses to toggle between two visual states of the tile. I seem to remember something like this from back when I wrote DataTree all those years ago. I think wait with messages somewhere in the code should prompt the handler to fire.
Perhaps a better way to handle this would be to use mouseDown to set the hilite state and mouseStillDown to track where the cursor is in relation to the tile.
Steve
Yes, the mouseDown handler contains a
Code: Select all
repeat while the mouse is down
Perhaps a better way to handle this would be to use mouseDown to set the hilite state and mouseStillDown to track where the cursor is in relation to the tile.
Steve
-
- VIP Livecode Opensource Backer
- Posts: 7214
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: MouseUp event isn't being triggered
The mouse messages that fire repeatedly aren't very reliable. You'd get better results by using "send <msg> in <time>" to do the tracking. The time can be a short number of milliseconds and the englne will do its housekeeping in between each call.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
-
- VIP Livecode Opensource Backer
- Posts: 9578
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: MouseUp event isn't being triggered
Jacque is quite expert at finding issues that can be fixed with just a little bit of "waiting".
Craig
Craig
-
- VIP Livecode Opensource Backer
- Posts: 7214
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: MouseUp event isn't being triggered
Maybe because I was asked to write an article about it:
https://www.hyperactivesw.com/resources_polling.html
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: MouseUp event isn't being triggered
Ah yes. I think I remember reading this some time ago.
Thanks for everybody's help here. if I refactor the code, this is the approach I'll take.
Steve
Thanks for everybody's help here. if I refactor the code, this is the approach I'll take.
Steve