Return-Values of WindowMouseX() and WindowMouseY()

Just starting out? Need help? Post your questions and find answers here.
Axolotl
Addict
Addict
Posts: 873
Joined: Wed Dec 31, 2008 3:36 pm

Return-Values of WindowMouseX() and WindowMouseY()

Post 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
Just because it worked doesn't mean it works.
PureBasic 6.04 (x86) and <latest stable version and current alpha/beta> (x64) on Windows 11 Home. Now started with Linux (VM: Ubuntu 22.04).
User avatar
mk-soft
Always Here
Always Here
Posts: 6320
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

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

Post by mk-soft »

Different OS behaviour.

Nice to see, but a bug Fred must say.
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Axolotl
Addict
Addict
Posts: 873
Joined: Wed Dec 31, 2008 3:36 pm

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

Post 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:
Just because it worked doesn't mean it works.
PureBasic 6.04 (x86) and <latest stable version and current alpha/beta> (x64) on Windows 11 Home. Now started with Linux (VM: Ubuntu 22.04).
Post Reply