Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
3 registered members (AndrewAMD, Ayumi, NewbieZorro), 14,141 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
[Solved] Detect double right click #424048
06/10/13 05:48
06/10/13 05:48
Joined: May 2008
Posts: 257
D
djfeeler Offline OP
Member
djfeeler  Offline OP
Member
D

Joined: May 2008
Posts: 257
Hello,

I would like to know how to detect twice the right click.

I have test, but I do not want that it waits.

Code:
if(mouse_right)
{	
	while(mouse_right == 1){ wait(1);}
	while(mouse_right == 0){ wait(1);}
}



I want detect directly the twice the right click.

Thanks in advance Djfeeler

Last edited by djfeeler; 06/10/13 06:47.
Re: detect double right click [Re: djfeeler] #424051
06/10/13 06:46
06/10/13 06:46
Joined: May 2008
Posts: 257
D
djfeeler Offline OP
Member
djfeeler  Offline OP
Member
D

Joined: May 2008
Posts: 257
Hello, I have find the solution :

Code:
#define CLICK_RATE 0.3  // Rate for the click double 

var VL_time_passed = 0;
var doubleclick_right = 0;

if(mouse_right)
{
	while(mouse_right){wait(1);}
	VL_time_passed = 0;
				
	while(VL_time_passed < CLICK_RATE)
	{
		if(mouse_right)
		{
			doubleclick_right = 1;
                        // action if the double click is made
		}
			VL_time_passed += time_step / 16;
			wait(1);
	}
}
else
{
	doubleclick_right = 0;
}



Djfeeler

Re: detect double right click [Re: djfeeler] #424053
06/10/13 07:50
06/10/13 07:50
Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
txesmi Offline
Serious User
txesmi  Offline
Serious User

Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
If it is important not to freeze the main loop that contains the code ( while(mouse_right){wait(1);} ), this is the simpliest way I know. It uses the 3dgs key events.

Code:
#include <acknex.h>
#define MC_DOUBLECLICKTIME		4
var nMouseLeft = 0;

void on_mouse_left_event ()
{
	nMouseLeft = 1;
}

function main ()
{
	mouse_mode = 4;
	
	wait(1);
	
	var nMouseClock = 0;
	
	while ( 1 )
	{
		if ( nMouseClock )
		{
			if ( nMouseLeft )
			{
				nMouseClock = 0;
				nMouseLeft = 0;
				error ( "Double click" );
			}
			else
			{
				nMouseClock = maxv ( nMouseClock - time_step, 0 );
				if ( nMouseClock == 0 )
				{
					error ( "Single click" );
				}
			}
		}
		else if ( nMouseLeft )
		{
			nMouseClock = MC_DOUBLECLICKTIME;
			nMouseLeft = 0;
		}
		
		wait(1);
	}
}



Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1