Page 1 of 1

MouseUp event isn't being triggered

Posted: Fri May 21, 2021 12:28 pm
by SteveFI
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

Re: MouseUp event isn't being triggered

Posted: Fri May 21, 2021 2:21 pm
by dunbarx
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

Re: MouseUp event isn't being triggered

Posted: Fri May 21, 2021 2:29 pm
by SteveFI
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

Re: MouseUp event isn't being triggered

Posted: Fri May 21, 2021 2:35 pm
by dunbarx
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

Re: MouseUp event isn't being triggered

Posted: Fri May 21, 2021 4:34 pm
by SteveFI
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

Re: MouseUp event isn't being triggered

Posted: Fri May 21, 2021 5:31 pm
by jacque
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.

Re: MouseUp event isn't being triggered

Posted: Fri May 21, 2021 5:36 pm
by SteveFI
Thanks Jacque.

Yes, the mouseDown handler contains a

Code: Select all

repeat while the mouse is down
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

Re: MouseUp event isn't being triggered

Posted: Fri May 21, 2021 5:50 pm
by jacque
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.

Re: MouseUp event isn't being triggered

Posted: Sat May 22, 2021 4:20 am
by dunbarx
Jacque is quite expert at finding issues that can be fixed with just a little bit of "waiting".

Craig

Re: MouseUp event isn't being triggered

Posted: Sat May 22, 2021 5:45 pm
by jacque
dunbarx wrote:
Sat May 22, 2021 4:20 am
Jacque is quite expert at finding issues that can be fixed with just a little bit of "waiting".
Maybe because I was asked to write an article about it:
https://www.hyperactivesw.com/resources_polling.html

Re: MouseUp event isn't being triggered

Posted: Mon May 24, 2021 9:47 am
by SteveFI
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