clientmousex() clientmousey()

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

clientmousex() clientmousey()

Post by blueznl »

it's rather silly that one has to resort to winapi to retrieve a mousepointer location

to keep old code functioning i would like to suggest to add these two commands that return the coordinates of the mouse in the client area

see also viewtopic.php?t=11233
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
GPI
PureBasic Expert
PureBasic Expert
Posts: 1394
Joined: Fri Apr 25, 2003 6:41 pm

Re: clientmousex() clientmousey()

Post by GPI »

At the moment the WindowX() and WindowY() functions are total useless, because they start outside the client-area (the gadget has a diffrent zero-point). And the problem: there is no PB-only way to find out, how big the "title-bar" of a window is, so nobody can translate the points.

It would be nice to change the WindowX() and WindowY() to client-Koordinates.

Code: Select all

  Id=GadgetID(gadget)
  GetCursorPos_(mouse.POINT)
  MapWindowPoints_(0,Id,mouse,1)
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Post by blueznl »

euh, gpi, you are refering to windowmousex() and windowmousey()? correct? :-)
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
GPI
PureBasic Expert
PureBasic Expert
Posts: 1394
Joined: Fri Apr 25, 2003 6:41 pm

Post by GPI »

blueznl wrote:euh, gpi, you are refering to windowmousex() and windowmousey()? correct? :-)
Yes...
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Post by blueznl »

then you stand corrected :-)
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post by thefool »

blueznl wrote:then you stand corrected :-)
:lol:
User avatar
Danilo
Addict
Addict
Posts: 3036
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Post by Danilo »

Code: Select all

; 
; by Danilo, 30.04.2003 - german forum
;
;   modified 11.12.2003
; 
Procedure WindowClientMouseX(win)             ; added param, 11.12.03
  ; Returns X-Position of MouseCursor 
  ; in the current window's client area 
  ; or -1 if mouse cursor isnt in this area. 
  GetCursorPos_(mouse.POINT) 
  ScreenToClient_(WindowID(win),mouse) 
  GetClientRect_(WindowID(win),rect.RECT) 
  If mouse\x < 0 Or mouse\x > rect\right 
    ProcedureReturn -1 
  ElseIf mouse\y < 0 Or mouse\y > rect\bottom ; added 11.12.03
    ProcedureReturn - 1
  Else 
    ProcedureReturn mouse\x 
  EndIf 
EndProcedure 

Procedure WindowClientMouseY(win)             ; added param, 11.12.03
  ; Returns Y-Position of MouseCursor 
  ; in the current window's client area 
  ; or -1 if mouse cursor isnt in this area. 
  GetCursorPos_(mouse.POINT) 
  ScreenToClient_(WindowID(win),mouse) 
  GetClientRect_(WindowID(win),rect.RECT) 
  If mouse\y < 0 Or mouse\y > rect\bottom 
    ProcedureReturn -1 
  ElseIf mouse\x < 0 Or mouse\x > rect\right  ; added 11.12.03
    ProcedureReturn - 1
  Else 
    ProcedureReturn mouse\y 
  EndIf 
EndProcedure 

OpenWindow(1,200,200,300,300,#PB_Window_SystemMenu,"MousePos") 

Repeat 
  Select WaitWindowEvent() 
    Case #PB_Event_CloseWindow 
      End 
    Default 
      StartDrawing(WindowOutput()) 
        Box(0,0,300,300,0) 
        DrawingMode(1):FrontColor($FF,$FF,$00) 
        Locate(30,100) 
        DrawText("MouseX: "+Str( WindowClientMouseX(1) )) 
        Locate(30,120) 
        DrawText("MouseY: "+Str( WindowClientMouseY(1) )) 
      StopDrawing()  
  EndSelect 
ForEver
Fred wanted to change WindowMouseX/Y to this code internally,
but looks like he forgot it...
cya,
...Danilo
...:-=< http://codedan.net/work >=-:...
-= FaceBook.com/DaniloKrahn =-
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

This is done now, for v3.91. As GPI said the current commands aren't really useful.
Post Reply