Page 1 of 1
Set Gadget's Position?
Posted: Wed May 27, 2020 6:43 pm
by Mythros
Hi all! How do you position a gadget AFTER said gadget has been created & resized using `ResizeGadget ( )` ?
Any help is GREATLY appreciated!
Thanks alot! <3
Re: Set Gadget's Position?
Posted: Wed May 27, 2020 6:50 pm
by Bisonte
Is this "Hidden camera" ?
With ResizeGadget() of course...
Re: Set Gadget's Position?
Posted: Wed May 27, 2020 7:14 pm
by Mythros
I think you misunderstand. I need to move the gadget AFTER ResizeGadget has been used so I can position the gadget in the middle of the screen constantly with the new size of the button being the width & height of the string the button uses.
Re: Set Gadget's Position?
Posted: Wed May 27, 2020 7:29 pm
by Erlend
Mythros wrote:I think you misunderstand. I need to move the gadget AFTER ResizeGadget has been used so I can position the gadget in the middle of the screen constantly with the new size of the button being the width & height of the string the button uses.
I think you need to reformulate you're question as what you are asking, Bisonte allready answered...
Re: Set Gadget's Position?
Posted: Wed May 27, 2020 7:31 pm
by Mythros
Ok, so say I wanted to position the button gadget AFTER resizing it to the width / height of the string so i can put it always in the middle of the screen based on its' new width / height. how can i do that?
Re: Set Gadget's Position?
Posted: Wed May 27, 2020 8:24 pm
by Erlend
Mythros wrote:Ok, so say I wanted to position the button gadget AFTER resizing it to the width / height of the string so i can put it always in the middle of the screen based on its' new width / height. how can i do that?
Do you mean the actual screen or the window? (Still not sure of you intent with this

)
For Window?:
Code: Select all
OpenWindow(0,0,0,300,300,"",#PB_Window_SizeGadget)
ButtonGadget(0,0,0,100,100,"ThisAndThat")
ResizeGadget(0,(WindowWidth(0)/2)-(GadgetWidth(0)/2),(WindowHeight(0)/2)-(GadgetHeight(0)/2),#PB_Ignore,#PB_Ignore)
Repeat
event=WaitWindowEvent()
If event=#PB_Event_SizeWindow
ResizeGadget(0,(WindowWidth(0)/2)-(GadgetWidth(0)/2),(WindowHeight(0)/2)-(GadgetHeight(0)/2),#PB_Ignore,#PB_Ignore)
EndIf
Until event=#PB_Event_CloseWindow
Re: Set Gadget's Position?
Posted: Wed May 27, 2020 8:42 pm
by wombats
You can use #PB_Ignore in place of X, Y, Width and Height if you don't want to modify it.
Re: Set Gadget's Position?
Posted: Wed May 27, 2020 10:07 pm
by BarryG
Mythros wrote:I need to move the gadget AFTER ResizeGadget has been used so I can position the gadget
The ResizeGadget() command can size
and move the gadget at the same time. It's not just for resizing.