Your is not a SOLUTION
It's a nice workaround for something that should be in PureBasic.
btw, this is the forum for feature requests, not for workaround requests
What looks best for a new user??
This:
Code: Select all
;-ExampleCode:
OpenWindow(0, 0, 0, 300, 200, #PB_Window_SystemMenu, "Test")
hWnd = WindowID()
If hWnd <> 0
CreateGadgetList(WindowID())
TextGadget(0, 10, 10, 280, 20, "Status")
Repeat
Event = WaitWindowEvent()
Select Event
Case #PB_Event_LButtonDown
SetGadgetText(0, "Left MouseButton pressed" )
Case #PB_Event_RButtonDown
SetGadgetText(0, "Right MouseButton pressed" )
Case #PB_Event_MButtonDown
SetGadgetText(0, "Middle MouseButton pressed")
EndIf
Until Event = #PB_Event_CloseWindow
EndIf
End
Or this
Code: Select all
Procedure WindowMouseButton(Wnd, ButtonNr)
CompilerIf #PB_Compiler_OS = #PB_OS_Linux
;Linux Version
Protected gdkWnd.l, x.l, y.l, mask.l
If Wnd
*Window.GTKWindow = Wnd
gdkWnd = *Window\bin\child\window
gdk_window_get_pointer_(gdkWnd, @x, @y, @mask)
Select ButtonNr
Case 0
If (mask & #GDK_BUTTON1_MASK)
ProcedureReturn 1
EndIf
Case 1
If (mask & #GDK_BUTTON3_MASK)
ProcedureReturn 1
EndIf
Case 2
If (mask & #GDK_BUTTON2_MASK)
ProcedureReturn 1
EndIf
EndSelect
EndIf
CompilerElse
;Windows Version
If Wnd And GetForegroundWindow_() = Wnd
Select ButtonNr
Case 0
If GetAsyncKeyState_(#VK_LBUTTON) > 0
ProcedureReturn 1
EndIf
Case 1
If GetAsyncKeyState_(#VK_RBUTTON) > 0
ProcedureReturn 1
EndIf
Case 2
If GetAsyncKeyState_(#VK_MBUTTON) > 0
ProcedureReturn 1
EndIf
EndSelect
EndIf
CompilerEndIf
ProcedureReturn 0
EndProcedure
;-ExampleCode:
OpenWindow(0, 0, 0, 300, 200, #PB_Window_SystemMenu, "Test")
hWnd = WindowID()
If hWnd <> 0
CreateGadgetList(WindowID())
TextGadget(0, 10, 10, 280, 20, "Status")
Repeat
Event = WindowEvent()
If WindowMouseButton(hWnd, 0)
SetGadgetText(0, "Left MouseButton pressed" )
ElseIf WindowMouseButton(hWnd, 1)
SetGadgetText(0, "Right MouseButton pressed" )
ElseIf WindowMouseButton(hWnd, 2)
SetGadgetText(0, "Middle MouseButton pressed")
EndIf
Delay(15)
Until Event = #PB_Event_CloseWindow
EndIf
End