[Implemented] Gadget-Lib: Flag to GadgetX and GadgetY

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
CSAUER
Enthusiast
Enthusiast
Posts: 188
Joined: Mon Oct 18, 2004 7:23 am
Location: Germany

[Implemented] Gadget-Lib: Flag to GadgetX and GadgetY

Post by CSAUER »

I would like to wish a additional flag to receive the absolute positions from GadgetX and GadgetY. The absolute positions are different to the relatives if you have nested gadgets inside a container. Then GadgetX and GadgetY provides you the relative position to the container and not the absolute position inside the window, which can be required to compare them with the absolute mouse position inside the window.

Maybe not a big deal for you, but very helpful for custom GUIs.
http://www.purebasic.fr/english/viewtop ... 684#218684
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PB4.1 - Win: MacBook black 2008 2,4 GHz, 4 GB RAM, MacOSX 10.5/VMWare/WinXP
PB4.1 - Mac: MacMini G4 1,4 GHz, 512 MB RAM, MacOSX 10.4
AND51
Addict
Addict
Posts: 1040
Joined: Sun Oct 15, 2006 8:56 pm
Location: Germany
Contact:

Post by AND51 »

Absolute coordinates?
But what yould you do, if you've got a button inside a ScrollAreagadget() ? If you scroll then, the position will be changed continiously (did I spell that word right^^).

This function would be nice, I appreciate it, although I can't think of a situaion spontaniously in which I could need it.
PB 4.30

Code: Select all

onErrorGoto(?Fred)
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

AND51 wrote:Absolute coordinates?
This function would be nice, I appreciate it, although I can't think of a situaion spontaniously in which I could need it.
Visual designer :wink:
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
AND51
Addict
Addict
Posts: 1040
Joined: Sun Oct 15, 2006 8:56 pm
Location: Germany
Contact:

Post by AND51 »

Sorry, I hardly use the Visual Designer. I create my GUIs manually... :oops:
PB 4.30

Code: Select all

onErrorGoto(?Fred)
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

AND51 wrote:Sorry, I hardly use the Visual Designer. I create my GUIs manually... :oops:
Sorry, I didn't meant using VD, but creating a VD.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
AND51
Addict
Addict
Posts: 1040
Joined: Sun Oct 15, 2006 8:56 pm
Location: Germany
Contact:

Post by AND51 »

Sorry, then I misunderstood you, gnozal.

And now: Stop the "sorrys"! :lol:
PB 4.30

Code: Select all

onErrorGoto(?Fred)
AND51
Addict
Addict
Posts: 1040
Joined: Sun Oct 15, 2006 8:56 pm
Location: Germany
Contact:

Post by AND51 »

@ CSAUER:
A workaround:

Code: Select all

Procedure GadgetAbsX(GadgetID)
	Protected pos.RECT
	GetWindowRect_(GadgetID(GadgetID), @pos)
	ProcedureReturn pos\left
EndProcedure
Procedure GadgetAbsY(GadgetID)
	Protected pos.RECT
	GetWindowRect_(GadgetID(GadgetID), @pos)
	ProcedureReturn pos\top
EndProcedure
  
  If OpenWindow(0, 0, 0, 305, 140, "ScrollAreaGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) And CreateGadgetList(WindowID(0))
    ScrollAreaGadget(0, 10, 10, 290,120, 375, 155, 30)
      ButtonGadget  (1, 10, 10, 230, 30,"Click me to get my abs. coords")
      CloseGadgetList() 
    Repeat 
      Select WaitWindowEvent() 
        Case  #PB_Event_CloseWindow 
          End 
        Case  #PB_Event_Gadget 
          Select EventGadget()
            Case 1
            	Debug GadgetAbsX(1)
          EndSelect
      EndSelect 
    ForEver 
  EndIf
As you see, this also works also with nested containers.
Is this what you want or do you want this natively?
PB 4.30

Code: Select all

onErrorGoto(?Fred)
Post Reply