Page 1 of 1

Return-Values of WindowMouseX() and WindowMouseY()

Posted: Wed Jul 17, 2024 2:53 pm
by Axolotl
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? :oops:
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

Re: Return-Values of WindowMouseX() and WindowMouseY()

Posted: Wed Jul 17, 2024 3:40 pm
by mk-soft
Different OS behaviour.

Nice to see, but a bug Fred must say.

Re: Return-Values of WindowMouseX() and WindowMouseY()

Posted: Wed Jul 17, 2024 5:11 pm
by Axolotl
Of course Fred decides on errors or features. :?:

If you say different OS behavior...
Isn't it the purpose of the PB functions to make it the same as much as it can?
Should I share my observations regarding different behavior or is that to boring at all?

I learnt today that I have to check on both X and Y if I want to be sure the mouse is moving outside the window. :oops: