Page 1 of 1

Please add GadgetMouseX / Y

Posted: Thu Dec 25, 2008 10:41 am
by technicorn
Happy Christmas!

Is it to late for Christmas wishes? ;)

Would be nice to have a GadgetMouseX / Y function to tell the position
relative to the upper left corner of a gadget,
I know it can be done with simple API funtions on Windows,
but it would be nice to have a cross platform funtion build in.

Peacefull Xmas to everyone
Technicorn

Posted: Thu Dec 25, 2008 7:44 pm
by Rescator
For like the ImageGadget you mean?
I think that would be better served by a EventMouse() or similar and that gadget supporting that.

Posted: Thu Dec 25, 2008 9:49 pm
by Trond

Code: Select all

Procedure GadgetMouseX(Gadget)
  ProcedureReturn WindowMouseX(0)-GadgetX(Gadget)
EndProcedure

Procedure GadgetMouseY(Gadget)
  ProcedureReturn WindowMouseX(0)-GadgetY(Gadget)
EndProcedure

Re: Please add GadgetMouseX / Y

Posted: Thu Dec 25, 2008 10:57 pm
by Psychophanta
technicorn wrote:Happy Christmas!

Is it to late for Christmas wishes? ;)

Would be nice to have a GadgetMouseX / Y function to tell the position
relative to the upper left corner of a gadget,
I know it can be done with simple API funtions on Windows,
but it would be nice to have a cross platform funtion build in.

Peacefull Xmas to everyone
Technicorn
Is not already implemented?
PB manual wrote:Syntax

Result = GadgetX(#Gadget)
Description

Returns the X position of the specified #Gadget. The X position is measured in pixels, starting from the inside of the left edge of the gadget list that the gadget is in.
Supported OS

All
If it is not what you are looking for, i think the Trond's way or:

Code: Select all

Macro GadgetMouseX(Window,Gadget)
  (WindowMouseX(Window#)-GadgetX(Gadget#))
EndMacro
Macro GadgetMouseY(Window,Gadget)
  (WindowMouseX(Window#)-GadgetY(Gadget#))
EndMacro
could help you. :)

Posted: Fri Dec 26, 2008 1:41 am
by technicorn
Thanks for trying to help, but that wouldn't do for gadgets in containers or panels, because you didn't know the offset for borders and alike,
one solution I found on this forum was:

Code: Select all

GetCursorPos_(p.POINT)
ScreenToClient_( GadgetID(#Gadget), p)
and it works, but is for Windows only.
I didn't know how this would be done under Linux and GDK for example!?

[Edit] Of course it should say GTK, not GDK

Posted: Tue Dec 30, 2008 6:11 am
by Erlend
For linux this would be:

Procedure GadgetMouseX(Gadget)
gtk_widget_get_pointer_(GadgeID(Gadget),@x,0)
ProcedureReturn x
EndProcedure
Procedure GadgetMouseY(Gadget)
gtk_widget_get_pointer_(GadgeID(Gadget),0,@y)
ProcedureReturn y
EndProcedure

Posted: Wed Dec 31, 2008 7:17 pm
by Rescator
So all we need now is the Mac equivalent and Fred can make API wrappers for all three platforms?
Or add EventMouse support of this to ImageGadget