It would be handy to have access to the last gadget defined.
Maybe already in the system somewhere.
I can think of many uses for (say) “#PB_LastGadget” including easy positioning of other gadgets.
You could define something like…
Global X,Y
Procedure Under()
Y=GadgetY(#PB_LastGadget)+GadgetHeight(#PB_LastGadget)+10
Endprocedure
Procedure RightSide()
X=GadgetX(#PB_LastGadget)+GadgetWidth(#PB_LastGadget)+10
Endprocedure
Openwindow(……..)
X=10 : Y=10
ListIconGadget(X,Y…..)
Under()
ButtonGadget(X,Y…..) : RightSide()
ButtonGadget(X,Y…..) : RightSide()
ButtonGadget(X,Y…..)
If I change the height of the ListIconGadget or want to move all the buttons a bit I only have to make minor changes as the gadgets are positioned relative to each other.
Cheers
#PB_LastGadget
Re: #PB_LastGadget
Been requested before:
http://www.purebasic.fr/english/viewtop ... =3&t=38528
The consensus was just to use a variable to track it.
http://www.purebasic.fr/english/viewtop ... =3&t=38528
The consensus was just to use a variable to track it.
Code: Select all
If OpenWindow(0, 200, 200, 222, 100, "ButtonGadgets", #PB_Window_SystemMenu)
x=10 : y=10
ButtonGadget(0, x, y, 200, 20, "Standard Button")
ButtonGadget(1, x, y+30, 200, 20, "Left Button", #PB_Button_Left)
ButtonGadget(2, x, y+60, 200, 20, "Right Button", #PB_Button_Right)
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
"PureBasic won't be object oriented, period" - Fred.
Re: #PB_LastGadget
I could indeed manually set a variable after every gadget I create or redefine all the gadgets to set this automatically but both methods create a lot of noise, hence my request.
PB is already creating a gadget list somewhere at a point in the code where #PB_LastGadget would be useful.
The example above is ok until I start swapping, resizing or adding something extra.
Cheers
PB is already creating a gadget list somewhere at a point in the code where #PB_LastGadget would be useful.
The example above is ok until I start swapping, resizing or adding something extra.
Cheers
Re: #PB_LastGadget
> #PB_LastGadget would be useful
In the other thread, "#TheNrOfTheLastGadgetIReferencedToInMyCode"
was requested, which is exactly what you're asking for... but the request
is now over 4 years old, so I doubt it's ever going to happen.
In the other thread, "#TheNrOfTheLastGadgetIReferencedToInMyCode"
was requested, which is exactly what you're asking for... but the request
is now over 4 years old, so I doubt it's ever going to happen.

I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
"PureBasic won't be object oriented, period" - Fred.