Page 1 of 1

separate single and double clicks?

PostPosted: Sat Apr 01, 2017 9:47 am
by Ethan
I have 1 object and 2 menus. I want to make it so that when the player single clicks on the object then menu 1 is called and when they double click the same object menu 2 is called.

However It seems that when you double click it registers as a single click first regardless of speed.

I've tried ordering the events so the double click happens before the single click code and using a variable to disable menu 1 from being called in this case, but with clicks being "on" events they appear to trigger before the variable change.

There may be an easy solution i'm not seeing.

Any one have any ideas?

Thanks.

Re: separate single and double clicks?

PostPosted: Sat Apr 01, 2017 11:10 am
by OddConfection
@Ethan

You could use an instance variable to count clicks and use a timer so that after 0.25 seconds it checks how many clicks, opens the appropriate menu, and resets the variable to 0

Example .capx (r233)

Re: separate single and double clicks?

PostPosted: Sat Apr 01, 2017 12:41 pm
by Ethan
@OddConfection Thanks for the example i'll take a look, but my worry is that if it doesnt appear instant then the pause might seem like lag.

Re: separate single and double clicks?

PostPosted: Sat Apr 01, 2017 12:50 pm
by OddConfection
@Ethan

No worries.

The delay is only a quarter of a second, which isn't very much at all.

You can shorten it if you want, it just needs to be long enough to do a double-click.

Re: separate single and double clicks?

PostPosted: Sat Apr 01, 2017 12:58 pm
by Ethan
Yes i shortened it slightly and it work greats, thanks for your help.