Return-Values of WindowMouseX() and WindowMouseY()
Posted: Wed Jul 17, 2024 2:53 pm
Some observations on the return values of the two functions:
If the mouse pointer is outside the window, -1 is displayed for both values under Win11.
Under Linux there are values <> -1. Looks like wrong behavior to me.... or maybe a bug?
Small test code:
If the mouse pointer is outside the window, -1 is displayed for both values under Win11.
Under Linux there are values <> -1. Looks like wrong behavior to me.... or maybe a bug?
Small test code:
Code: Select all
Macro RStr(Value, Length)
RSet(Str(Value), Length)
EndMacro
If OpenWindow(0, 0, 0, 320, 120, "Example...", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
StickyWindow(0, 1)
TextGadget(1, 10, 10, 300, 20, "")
TextGadget(2, 10, 40, 300, 20, "")
AddWindowTimer(0, 1, 100)
Repeat
Event = WaitWindowEvent()
Select Event
Case #PB_Event_DeactivateWindow : Debug "bye "
Break
Case #PB_Event_Timer
mx = DesktopMouseX()
my = DesktopMouseY()
SetGadgetText(1, "Desktop Mouse Pos: " + RStr(mx, 4) + ", " + RStr(my, 4))
mx = WindowMouseX(0)
my = WindowMouseY(0)
SetGadgetText(2, "Window Mouse Pos: " + RStr(mx, 4) + ", " + RStr(my, 4))
EndSelect
Until Event = #PB_Event_CloseWindow
EndIf