EVT_MOUSEBUTTONDOWN and EVT_MOUSEBUTTONUP use

Pixilang programming language
Post Reply
pasbel
Posts: 18
Joined: Mon Jul 02, 2012 2:19 pm

EVT_MOUSEBUTTONDOWN and EVT_MOUSEBUTTONUP use

Post by pasbel » Mon Apr 25, 2016 3:52 pm

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

pasbel
Posts: 18
Joined: Mon Jul 02, 2012 2:19 pm

Re: EVT_MOUSEBUTTONDOWN and EVT_MOUSEBUTTONUP use

Post by pasbel » Mon Apr 25, 2016 4:08 pm

:O:
I must use :

Code: Select all

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

Post Reply