MouseUp event isn't being triggered

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
SteveFI
Posts: 30
Joined: Tue Mar 16, 2021 6:15 pm

MouseUp event isn't being triggered

Post by SteveFI » Fri May 21, 2021 12:28 pm

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

dunbarx
VIP Livecode Opensource Backer
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

Post by dunbarx » Fri May 21, 2021 2:21 pm

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

SteveFI
Posts: 30
Joined: Tue Mar 16, 2021 6:15 pm

Re: MouseUp event isn't being triggered

Post by SteveFI » Fri May 21, 2021 2:29 pm

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

dunbarx
VIP Livecode Opensource Backer
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

Post by dunbarx » Fri May 21, 2021 2:35 pm

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

SteveFI
Posts: 30
Joined: Tue Mar 16, 2021 6:15 pm

Re: MouseUp event isn't being triggered

Post by SteveFI » Fri May 21, 2021 4:34 pm

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

jacque
VIP Livecode Opensource Backer
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

Post by jacque » Fri May 21, 2021 5:31 pm

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.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

SteveFI
Posts: 30
Joined: Tue Mar 16, 2021 6:15 pm

Re: MouseUp event isn't being triggered

Post by SteveFI » Fri May 21, 2021 5:36 pm

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

jacque
VIP Livecode Opensource Backer
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

Post by jacque » Fri May 21, 2021 5:50 pm

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

dunbarx
VIP Livecode Opensource Backer
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

Post by dunbarx » 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".

Craig

jacque
VIP Livecode Opensource Backer
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

Post by jacque » Sat May 22, 2021 5:45 pm

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
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

SteveFI
Posts: 30
Joined: Tue Mar 16, 2021 6:15 pm

Re: MouseUp event isn't being triggered

Post by SteveFI » Mon May 24, 2021 9:47 am

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

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”