Page 1 of 1

EVT_MOUSEBUTTONDOWN and EVT_MOUSEBUTTONUP use

Posted: Mon Apr 25, 2016 3:52 pm
by pasbel
Hi
I try to use this function, but...
I want to use mouse to activate something with a mouse-left-click. But, mouse click is sent 2 times, one when mouse button is down, and another one when mouse button up.
I tried to use EVT_MOUSEBUTTONDOWN (and EVT_MOUSEBUTTONUP), but I don't understand how to use it with KEY_MOUSE_LEFT.
If someone could help me :cry: , example bellow :

Code: Select all

xsize = get_xsize( get_screen() )
ysize = get_ysize( get_screen() )
x0 = - xsize div 2
y0 = - ysize div 2
fbox ( x0 , y0 , xsize , ysize , #666666 )
x = x0 + 10
y = y0 + 10
l = 100
h = 20
fbox ( x , y , l , h , WHITE )
frame()
cursor = 40

main_loop = 1
while( main_loop == 1 ){
	while( get_event() ){
		mouse_posx = EVT[ EVT_X ]
		mouse_posy = EVT[ EVT_Y ]
		if mouse_posx > x && mouse_posx < x + l && mouse_posy > y && mouse_posy <= y + h {
			if ( EVT[ EVT_KEY ] & KEY_MOUSE_LEFT ){
				print ( "bouton" , x0 , y0 + cursor , WHITE , TOP|LEFT )
				cursor = cursor + 10
				frame()
			}//endif
		}//endif
	}//end while
}//end while

Re: EVT_MOUSEBUTTONDOWN and EVT_MOUSEBUTTONUP use

Posted: Mon Apr 25, 2016 4:08 pm
by pasbel
:O:
I must use :

Code: Select all

if ( EVT[ EVT_KEY ] & KEY_MOUSE_LEFT && EVT[ EVT_TYPE ] & EVT_MOUSEBUTTONDOWN ){