Mouse and Keyboard Events should be available for Windows!
Posted: Mon Nov 11, 2024 11:46 am
Why are Mouse & Keyboard Events only available for Gadgets?
-> #PB_Event_Gadget / #PB_Event_SysTray
Why is it not available for a Window ?
This would help a lot for anything custom on the window.
Ex. it would allow a WindowedScreen with a mouse that is not captured!
I really dont understand this and im tired of coding workarounds!
It would be nice to get support for:
Edit:
Added example code below.
Example (just like the CanvasGadget works):
-> #PB_Event_Gadget / #PB_Event_SysTray
Why is it not available for a Window ?
This would help a lot for anything custom on the window.
Ex. it would allow a WindowedScreen with a mouse that is not captured!
I really dont understand this and im tired of coding workarounds!
It would be nice to get support for:
Code: Select all
#PB_EventType_MouseEnter
#PB_EventType_MouseLeave
#PB_EventType_MouseMove
#PB_EventType_MouseWheel
#PB_EventType_LeftButtonDown
#PB_EventType_LeftButtonUp
#PB_EventType_LeftClick
#PB_EventType_RightClick
#PB_EventType_LeftDoubleClick
#PB_EventType_RightDoubleClick
#PB_EventType_Focus
#PB_EventType_LostFocus
Added example code below.
Example (just like the CanvasGadget works):
Code: Select all
EnableExplicit
Procedure.i Example()
Protected click.i
If OpenWindow(0,0,0,320,200,#Null$,#PB_Window_SystemMenu|#PB_Window_WindowCentered)
If CanvasGadget(0,0,0,WindowWidth(0),WindowHeight(0))
Repeat
Repeat
Select WindowEvent()
Case #PB_Event_Gadget
Select EventType()
Case #PB_EventType_LeftButtonDown
click = #True
Case #PB_EventType_LeftButtonUp
click = #False
EndSelect
Case #PB_Event_None
Break
Case #PB_Event_CloseWindow
Break 2
EndSelect
ForEver
If StartDrawing(CanvasOutput(0))
Box(0,0,WindowWidth(0),WindowHeight(0),#Black)
DrawText(0,0,"MOUSE: " + Str(WindowMouseX(0)) + " x " + Str(WindowMouseY(0)))
DrawText(0,32,"LEFT MOUSE BUTTON DOWN: " + Str(click))
StopDrawing()
EndIf
ForEver
EndIf
CloseWindow(0)
EndIf
EndProcedure
End Example()