Hello, I have a question.
Is there an API command for returning where the mouse cursor is on a specific gadget?
For example, "WindowMouseX()" returns the cursor location correspondin to the upper left point of the window.
I want to know if there is a way to return the cursor corrseponding to the upper left point of a gadget.
Any advice will be appreciated, thank you
-Shopro
GadgetMouseX() ?
Hi,
you could try it like this (workaround):
Returns the relative X/Y to your gadget - you just have to be careful with the height of the titlebar and the size of the borders (otherwise you won't get the exact position of the gadget).
Maybe there's a better way but I was too lazy to make an example - check these API functions:
ClientToScreen_
GetCursorPos_
Hope I could help you
you could try it like this (workaround):
Code: Select all
Procedure getRelativeX(myGadget.l)
ProcedureReturn WindowMouseX()-GadgetX(myGadget)
EndProcedure
Procedure getRelativeY(myGadget.l)
HeightOfTitleBar = 20
ProcedureReturn WindowMouseY()-GadgetY(myGadget)-HeightOfTitleBar
EndProcedure
Maybe there's a better way but I was too lazy to make an example - check these API functions:
ClientToScreen_
GetCursorPos_
Hope I could help you
V2
-
freedimension
- Enthusiast

- Posts: 613
- Joined: Tue May 06, 2003 2:50 pm
- Location: Germany
- Contact:
Code: Select all
p.POINT
p\x = WindowMouseX()
p\y = WindowMouseY()
ScreenToClient_( GadgetID(#Gadget), p)
DON'T MAKE IT SO! The height of the Tilebar is not a fixed size. Every user can change this!V2 wrote:Code: Select all
Procedure getRelativeX(myGadget.l) ProcedureReturn WindowMouseX()-GadgetX(myGadget) EndProcedure Procedure getRelativeY(myGadget.l) HeightOfTitleBar = 20 ProcedureReturn WindowMouseY()-GadgetY(myGadget)-HeightOfTitleBar EndProcedure
-
freedimension
- Enthusiast

- Posts: 613
- Joined: Tue May 06, 2003 2:50 pm
- Location: Germany
- Contact:
Oops, mine is false too.
Use instead this one (it's even shorter and faster)
Use instead this one (it's even shorter and faster)
Code: Select all
GetCursorPos_(p.POINT)
ScreenToClient_( GadgetID(#Gadget), p)
Thankyou!
Just wanted to say a huge THANKYOU for this post, because its got me out of a really irratating hole. I was so depressed, that I couldn't find a way of doing this reliably.
My concern was that I couldn't work out where the mouse was in relation to a button within a ScrollAreaGadget. But this API call takes care of that too - so yeah, I'm happy! My first project is back on course!
Thanks again!
My concern was that I couldn't work out where the mouse was in relation to a button within a ScrollAreaGadget. But this API call takes care of that too - so yeah, I'm happy! My first project is back on course!
Thanks again!
There are 10 types of people in life. Those who understand binary, and those that don't.


