Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
0 registered members (), 984 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
LucasJoshua, Baklazhan, Hanky27, firatv, wandaluciaia
19053 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 | chip programmers | 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