Show/Hide a GUI button
by Robert S. · in Torque Game Engine · 11/06/2005 (9:24 am) · 3 replies
Hi,
I have a GuiBitmapButtonCtrl in my playerGUI.gui which doesn't always have to be visible. Depending on the content of the scene, it can be visible or hidden.
Please tell me how I can control it via script. I tried the following, but it doesn't work:
playerGui.gui:
.........................
$Button_ToShowHide = new GuiBitmapButtonCtrl() {......}
.........................
in my server script I tried the following, but without success because $Button_ToShowHide is null:
$Button_ToShowHide.visible = true; or
$Button_ToShowHide.visible = false;
Thank you.
I have a GuiBitmapButtonCtrl in my playerGUI.gui which doesn't always have to be visible. Depending on the content of the scene, it can be visible or hidden.
Please tell me how I can control it via script. I tried the following, but it doesn't work:
playerGui.gui:
.........................
$Button_ToShowHide = new GuiBitmapButtonCtrl() {......}
.........................
in my server script I tried the following, but without success because $Button_ToShowHide is null:
$Button_ToShowHide.visible = true; or
$Button_ToShowHide.visible = false;
Thank you.
About the author
Creator of VisitorVille.com
#2
elsewhere...
GuiControl's setVisible method not only sets the visibility state, but also sets its update flag and a couple other things. You might also want to call setActive( false) so that your user can't click on an invisible button. Watch out for a bug, though. Some controls can get stuck if they're disabled while in a mouse-down state.
11/07/2005 (8:08 am)
Have you tried:new GuiBitmapButtonCtrl( Button_ToShowHide) {
...
visible = "0"; // not seen by default
};elsewhere...
Button_ToShowHide.setVisible( true);
GuiControl's setVisible method not only sets the visibility state, but also sets its update flag and a couple other things. You might also want to call setActive( false) so that your user can't click on an invisible button. Watch out for a bug, though. Some controls can get stuck if they're disabled while in a mouse-down state.
#3
11/08/2005 (5:24 am)
Thank you very much for your answers. They really helped me.
Torque Owner Kevin Johnson
www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=1839