Game Development Community

Getting a window to not take control

by Ricky Taylor · in Torque Game Builder · 12/17/2005 (2:17 pm) · 3 replies

Is there a way to make a guiWindow that doesnt take complete control?

I need to be able to click buttons on the origional Gui...

Also, can you dynamically add controls to Guis?

Thanks in advanced.
Ricky,

#1
12/17/2005 (8:47 pm)
Yes, it is possible to make a GuiWindowCtrl that doesn't take control - just add it to the GUI. It is not possible, however, to bring thatf GUI into view with the Canvas.pushDialog or Canvas.setContent and not have it take control (please correct me if I'm wrong).

Yes, you can dynamically create controls. Let's say you have a GUI named MainWindowGui. Inside the script, you'd put:

new GuiButtonCtrl ( newBtn ) {
   profile = "GuiButtonProfile";
   position = "10 10";
   extent = "10 10";
   text = "X";
   command = "MainWindowGui.newBtnPressed ( \"New Button\" );";
   buttonType = "PushButton";
};

You'd also need the command available:

function MainWindowGui.newBtnPressed ( %this, %val )
{
   MessageBoxOk ( "PRESS", "The " @ %val @ " button was pressed." );
}

Ok, that creates the control. You can't see it yet. You need to also call:

MainWindowGui.add ( newBtn );

Now you'll see your shiny new button. This, of course, would work for any of the GUI controls. Calling the "add" is the key.

(edit: updated the code a little)
#2
12/17/2005 (11:01 pm)
You can actually pop up separate GUIs with pushDialog() and still click through to other guis behind it, if you've set "modal = false" in the profile that you use for the front-most gui control. GuiDefaultProfile sets 'modal = true' by default so nothing exhibits this behavior out of the box.

I'd recommend creating a new profile that inherits GuiDefaultProfile, and set 'modal = false' in that, and use that for the controls that you pop up over others (or if you're already using your own custom profiles, just add 'modal = false' to those).

Takes a little experimentation to get it to do exactly what you want, but it is possible.
#3
12/18/2005 (12:03 pm)
Excellent! The non-modal dialogs is just mainGameGui.add! Thanks LOADS!

Although the profile idea seems more robust....

This is just what I needed!