Disabling GUI controls?
by Geom · in Torque Game Engine · 04/28/2006 (12:14 pm) · 7 replies
Anyone know if Torque has a function to programmatically enable/disable Torque's GUI controls?
I'm basically looking for an equivalent to win32's EnableWindow() function. I want to use it on GuiPopUpMenuCtrl's, GuiTextEditCtrl's, and GuiCheckBoxCtrl's. I snooped around the C++ source and did some dump()s, but didn't see anything that looked like it'd do what I want.
thx. BTW this is with TGE 1.3.
I'm basically looking for an equivalent to win32's EnableWindow() function. I want to use it on GuiPopUpMenuCtrl's, GuiTextEditCtrl's, and GuiCheckBoxCtrl's. I snooped around the C++ source and did some dump()s, but didn't see anything that looked like it'd do what I want.
thx. BTW this is with TGE 1.3.
About the author
My email address is my GG handle, at redbrickgames.com.
#2
I ran a few tests with setActive(false). Here's what I found:
GuiPopUpMenuCtrl:
no effect, appearance of control doesn't change, and user can still change selection
GuiTextEditCtrl:
seems to be partly implemented; text turns light grey to indicate control is disabled, and tabbing around the dialog skips the control, but the user can still edit the control's text!
GuiCheckBoxCtrl:
fully implemented; background of check box turns light grey, and user can't alter the check mark
GuiButtonCtrl:
fully implemented, except that the button's appearance doesn't change, so there's no visual cue that the button is disabled
Interesting.
04/28/2006 (1:10 pm)
Thx Owen, it looks like setActive() is indeed what I want. Unfortunately...it also looks like setActive() is only partly implemented, or not implemented, for many controls.I ran a few tests with setActive(false). Here's what I found:
GuiPopUpMenuCtrl:
no effect, appearance of control doesn't change, and user can still change selection
GuiTextEditCtrl:
seems to be partly implemented; text turns light grey to indicate control is disabled, and tabbing around the dialog skips the control, but the user can still edit the control's text!
GuiCheckBoxCtrl:
fully implemented; background of check box turns light grey, and user can't alter the check mark
GuiButtonCtrl:
fully implemented, except that the button's appearance doesn't change, so there's no visual cue that the button is disabled
Interesting.
#3
I had a similar problem with a button ctrl... and I managed to get around it... don't remember right off how I did it (at work) but I had to work in the onWake function of the control or the screen..
IF I CAN remember, when I get home, I'll take a lot at how I fudged it.
04/28/2006 (1:22 pm)
When the control "wakes" up, it will set the control to active regardless of how you setActive() the ctrl. It wakes up when the gui canvas loads the screen that you want then it goes through all the children of that screen and "wakes" them up AND activates them.I had a similar problem with a button ctrl... and I managed to get around it... don't remember right off how I did it (at work) but I had to work in the onWake function of the control or the screen..
IF I CAN remember, when I get home, I'll take a lot at how I fudged it.
#4
I ran my tests from Torque's console window, so the waking effect wouldn't have come into play there (good to know about that though). I just did another quick test with just the text edit control, this time with Torque 1.4. Same result, the control looks disabled, but isn't really. setActive() seems to be a feature that hasn't been fully implemented across all controls.
04/28/2006 (1:53 pm)
@Steve thanks, I would be interested to know if there's an easy fix.I ran my tests from Torque's console window, so the waking effect wouldn't have come into play there (good to know about that though). I just did another quick test with just the text edit control, this time with Torque 1.4. Same result, the control looks disabled, but isn't really. setActive() seems to be a feature that hasn't been fully implemented across all controls.
#5
Doing a search for setActive, I see hardly any chatter about it...I guess I'm pushing the envelope of Torque GUI controls. My problem is that I have this monster setup dialog, for an RTS game:

so I need lots of "control" in over my GUI controls (no pun intented).
04/28/2006 (2:10 pm)
A somewhat related thread is here -> www.garagegames.com/mg/forums/result.thread.php?qt=36926 although it only addresses disabling button controls.Doing a search for setActive, I see hardly any chatter about it...I guess I'm pushing the envelope of Torque GUI controls. My problem is that I have this monster setup dialog, for an RTS game:

so I need lots of "control" in over my GUI controls (no pun intented).
#6
For the button (I finally fully read what what you were saying about the controls). The buttons don't change. You probably want to use GuiBitmapButtonCtrl (or GuiBitmapButtonTextCtrl) and create 4 bitmaps to represent the states. Normal, Highlight, pressed, and inactive. I hardly use the regular GuiButtonCtrl,, I think that's more of a very generic basic button or as a "base" for derived classes. Which in that case you'd probably want to handle the Inactive"ivity" differently.
So you're probably correct in that the GuiButtonCtrl hasn't completed the inActive state. as it assumes that the derived classes would handle it and handle it differently.
04/28/2006 (2:30 pm)
From the look of your dialog.. you shouldn't have a problem using setActive. In mine.. I use it all the time.For the button (I finally fully read what what you were saying about the controls). The buttons don't change. You probably want to use GuiBitmapButtonCtrl (or GuiBitmapButtonTextCtrl) and create 4 bitmaps to represent the states. Normal, Highlight, pressed, and inactive. I hardly use the regular GuiButtonCtrl,, I think that's more of a very generic basic button or as a "base" for derived classes. Which in that case you'd probably want to handle the Inactive"ivity" differently.
So you're probably correct in that the GuiButtonCtrl hasn't completed the inActive state. as it assumes that the derived classes would handle it and handle it differently.
#7
I need to be able to disable those PopUpMenuCtrls because this is a multiplayer dialog. A player should be able to see other players' race, team, etc., but he shouldn't be able to edit them. Actually at any given time *most* of the controls on the dialog need to be disabled from the perspective of a given player, only the player's own controls should be enabled for him.
I'll see about implementing setActive(false) for PopUpMenuCtlrs and TextEditCtrls, it might be easy and be a useful resource.
04/29/2006 (12:28 pm)
The problem tho is those are all PopUpMenuCtrls on my dialog (not buttons), so the button solution doesn't work for me here.I need to be able to disable those PopUpMenuCtrls because this is a multiplayer dialog. A player should be able to see other players' race, team, etc., but he shouldn't be able to edit them. Actually at any given time *most* of the controls on the dialog need to be disabled from the perspective of a given player, only the player's own controls should be enabled for him.
I'll see about implementing setActive(false) for PopUpMenuCtlrs and TextEditCtrls, it might be easy and be a useful resource.
Torque Owner Owen Ortmayer