Please add GadgetMouseX / Y

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
technicorn
Enthusiast
Enthusiast
Posts: 105
Joined: Wed Jan 18, 2006 7:40 pm
Location: Hamburg

Please add GadgetMouseX / Y

Post 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
User avatar
Rescator
Addict
Addict
Posts: 1769
Joined: Sat Feb 19, 2005 5:05 pm
Location: Norway

Post 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.
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

Code: Select all

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

Procedure GadgetMouseY(Gadget)
  ProcedureReturn WindowMouseX(0)-GadgetY(Gadget)
EndProcedure
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Re: Please add GadgetMouseX / Y

Post 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. :)
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
technicorn
Enthusiast
Enthusiast
Posts: 105
Joined: Wed Jan 18, 2006 7:40 pm
Location: Hamburg

Post 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
User avatar
Erlend
Enthusiast
Enthusiast
Posts: 114
Joined: Mon Apr 19, 2004 8:22 pm
Location: NORWAY

Post 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
User avatar
Rescator
Addict
Addict
Posts: 1769
Joined: Sat Feb 19, 2005 5:05 pm
Location: Norway

Post 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
Post Reply