DoubleClick event without Click event?

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

cyberjunk
Not too shy to talk
Not too shy to talk
Posts: 25
Joined: Fri Jan 17, 2014 02:39

DoubleClick event without Click event?

Postby cyberjunk » Thu Feb 06, 2014 08:38

Hello,

is it possible to get a mouse DoubleClick event without also getting a Click event?

It basically does not matter which widget I try...
If I subscribe both, the mouse click event and the double-click event and then do a double-click on the widget, both of my event handlers are executed.

But I'd like to have totally different actions assigned to single-click and double-click, is this possible?
I checked the "setSingleClickTimeout" and "setMultiClickTimeout", but they don't seem to be a solution to my issue, more likely they sound like this is the default behaviour.

Thanks.

Edit:
I know I can basically code this on my own, by just setting a flag and saving a tick/timestamp in the mouseclick event, and then execute the actual code after a delay from the timestamp and if the double-click handler does not flip the flag back... but I really thought there's an internal solution ...

User avatar
Ident
CEGUI Team
Posts: 1998
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: DoubleClick event without Click event?

Postby Ident » Fri Feb 07, 2014 14:52

Can you write us a reproduction/demo of this issue as part of a ticket on mantis bug tracker? this sounds like a bug. but we need to be able to reproduce it to fix it.

You could also try to debug the CEGUI code to see where this problem occurs, which will probably help you to find a quick fix for this, and create a Pull Request on mercurial for the fix.

It might also be that everything is working as intended. To be honest I have absolutely no idea about this part of CEGUI. However the timeouts seem to just apply to repeated clicking and are not related to multi vs singleclick differentiation as far as I understand.
CrazyEddie: "I don't like GUIs"

cyberjunk
Not too shy to talk
Not too shy to talk
Posts: 25
Joined: Fri Jan 17, 2014 02:39

Re: DoubleClick event without Click event?

Postby cyberjunk » Mon Feb 10, 2014 08:32

Hey Ident,

thanks again for all your responses :-)
Are you sure this is a bug?

I've investigated this a little further, for example this thread states that a single-click is always raised before a double-click:
viewtopic.php?f=5&t=4034

It seems to me this is the default behaviour..

And I think there is an understandable reason it's the way it is.. the issue with having a "double-click" without a single-click is:
You would have to delay the execution of the single-click code (or delay raise of the event) until you decided: "OK, no second click occured". I played around with values and now I've set my own implementation to 250ms. So if you do a single click, basically "nothing" happens for 250ms because the code is waiting for: "is there another click?". If there is, I'm executing my double-click code, if there isn't, I'm executing my single-click code. However this "feels" a bit strange, because 250ms is long enough to make the delay for single-click and the expected resulting action slightly notable to the user, so for example if a "pro gamer" clicks mouse with one hand and immediately presses a keyboard hotkey with other hand, a hotkey wich is supposed to interact with the click-result (like target something (single leftclick) an trigger an attack/action (keyboard hotkey)), then you get into trouble... But on the other side anything lower than 250ms tends to create 2 single-clicks if you don't press the buttons ultra fast. So there is no perfect solution for what I want.

So in conclusion I think the best is:
The semantics of the single-click and the double-click probably should not interfere. A typical good example is to "select" with left-mouseclick and to "execute" with double-click. This is the typical "filemanager/explorer" example. So a single-click action should basically be a subset of a double-click.

User avatar
Ident
CEGUI Team
Posts: 1998
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: DoubleClick event without Click event?

Postby Ident » Mon Feb 10, 2014 14:50

One way to distinguish single and double-click would be to be able to query if the single click will also be triggering a double click. This query could be done in a single-click event handler, and if the function to query this returns the boolean, then you could act accordingly. However, like you described, there is no way to solve this for the first click of the double click, so this is just a solution for the second click and I think this is barely ever actually needed at all, because:

A typical good example is to "select" with left-mouseclick and to "execute" with double-click.

In which case the single-click is ALSO triggered (try it out, the folder gets selected first which is a single-click effect). So as you see, this is handled the same way in your example, as it is in CEGUI.

I don't consider this a bug anymore. It works as intended and is done equally in games and applications. You have to design your interactions differently, I guess. And actually in games double-clicks are not often used anyways, and if they are used, then they dont interefere with the actions from the single clicks.
CrazyEddie: "I don't like GUIs"


Return to “Help”

Who is online

Users browsing this forum: No registered users and 27 guests