click vs doubleclick in hotspots

Posted by Zimmy on Tue 05 Nov 2019 03:29 AM — 6 posts, 24,280 views.

#0
I would like to have two completely different things happen depending on whether I right-click or double-click on a hotspot. The problem I'm having now is that if I double-click then the single-click will still activate first. How would I make it so that if I double-click the sing-click event doesn't happen first?
Australia Forum Administrator #1

Can you clarify two things?

  • Are you doing two completely different things on double-click compared to single-click? Typically in many applications (eg. Windows desktop) a single click selects, and a double-click opens. Thus the single click is not incompatible with the (following) second click.

  • Are you performing the action on mouse-down or the subsequent mouse-up? Typically actions are performed on a mouse-up.

#2
I was just using mousedown. Basically I have a little map and I want to make it so that if I single click I look at a room and if I double click I actually move to it.
Australia Forum Administrator #3
First, most programs react to a mouse-up to do an action rather than a mouse-down.

This lets you change your mind if you inadvertently click on the wrong room, for example. You can move the mouse away to some neutral spot and then release the mouse.

You will probably find it more like normal behaviour to implement your actions on mouse-up.

Now what you can do is "remember" when the mouse-down occurred, and then see how long elapsed between the mouse-down and the next mouse-up. That way you could make a short press be look at the room contents, and press and hold for half a second be move to that room.
#4
Thanks, I guess I could also have single click work on a delay that gets canceled if double-click happens first. However, I didn't want to sacrifice speed so I ended up just switching to right/left click. I also, switched to mouseup, thanks for pointing that out!
Australia Forum Administrator #5
In my mapper I think I had LH click to move and RH click for more information about the room. You can also add Ctrl/Shift/Alt to both LH and RH clicks, so that is 6 different combinations right there!

Your idea of the delayed single-click action is also something I was going to suggest. You could make a temporary timer to show something after 0.7 seconds, and cancel it if you get a double-click after 0.5 seconds.

Another option (on the mouse-up) is to use the WindowMenu to pop up a small menu on a RH click, eg.


View
Go to
Info
Bookmark


Template:function=WindowMenu
WindowMenu

The documentation for the WindowMenu script function is available online. It is also in the MUSHclient help file.



Alternatively show the menu on a mouse-up if more than (say) 0.5 seconds have elapsed. So, a short click (down/up) will move you to the room, and a longer click shows the menu, and you choose what to do.