Page 1 of 1

#PB_EventType_LeftClick [weird bug]

Posted: Mon Oct 09, 2023 1:07 pm
by naf
Hi !
I get this weird bug of an invading #PB_EventType_LeftClick as soon as I open a window. I checked mouse function, sensitivity, other things... What's going on ???
First goal was typing on a canvas, but the invading #PB_EventType_LeftClick doesn't let the keyboard events showing up.

Code: Select all

OpenWindow(0,3,3, 700,400,"FPBUX for paramWindow etc.",
	#PB_Window_ScreenCentered|#PB_Window_SystemMenu|#PB_Window_SizeGadget)

;	CanvasGadget(1,50,50,333,333,#PB_Canvas_Keyboard|#PB_Canvas_DrawFocus)

Debug "-------------------"
Repeat
	ev=WaitWindowEvent(5)
	Select ev
		Case #PB_EventType_KeyDown
			Debug "*** key down ***"
		Case #PB_EventType_Input
			Debug "*** input ***"
		Case #PB_EventType_Focus
			Debug "--Focus." 
		Case #PB_EventType_LostFocus 
			Debug "--Lost focus."
		Case #PB_EventType_LeftClick ; Invader!!!
			Debug "@@@ left click."
	EndSelect
		
Until ev=#PB_Event_CloseWindow
I get :
[11:15:10] [Debug] @@@ left click.
[11:15:10] [Debug] @@@ left click.
[11:15:10] [Debug] @@@ left click.
[11:15:10] [Debug] @@@ left click.
[11:15:10] [Debug] @@@ left click.
[11:15:10] [Debug] @@@ left click.
[11:15:10] [Debug] @@@ left click.
[11:15:10] [Debug] @@@ left click.
[11:15:10] [Debug] @@@ left click.
[11:15:10] [Debug] @@@ left click.
[11:15:10] The Program execution has finished.
//PureBasic_Windows_X64_LTS_6.02 // windows 10 // thinkpad T460s//

Re: #PB_EventType_LeftClick [weird bug]

Posted: Mon Oct 09, 2023 1:34 pm
by spikey
It's not a bug - well not in PB anyway. :)
WaitWindowEvent() returns a #PB_Event constant not a #PB_EventType constant. See WindowEvent() for the right list of response values.

What you are getting back is zero, indicating "no event before the timeout". You need to allow for this because you're using a non-zero timeout value.

The values you're selecting on are returned by EventType().

Re: #PB_EventType_LeftClick [weird bug]

Posted: Mon Oct 09, 2023 1:48 pm
by STARGĂ…TE
You missed some Select statements:

Code: Select all

OpenWindow(0,3,3, 700,400,"FPBUX for paramWindow etc.",	#PB_Window_ScreenCentered|#PB_Window_SystemMenu|#PB_Window_SizeGadget)
CanvasGadget(1,50,50,333,333,#PB_Canvas_Keyboard|#PB_Canvas_DrawFocus)
Repeat
	ev=WaitWindowEvent(5)
	Select ev
		Case #PB_Event_Gadget
			Select EventGadget()
				Case 1
					Select EventType()
						Case #PB_EventType_KeyDown
							Debug "*** key down ***"
						Case #PB_EventType_Input
							Debug "*** input ***"
						Case #PB_EventType_Focus
							Debug "--Focus." 
						Case #PB_EventType_LostFocus 
							Debug "--Lost focus."
						Case #PB_EventType_LeftClick ; Invader!!!
							Debug "@@@ left click."
					EndSelect
			EndSelect
	EndSelect
Until ev=#PB_Event_CloseWindow