Game Development Community

Stacking windows in a pile

by Eero Karvonen · in Torque 2D Beginner · 06/13/2014 (12:33 pm) · 5 replies

I have one master window in which I add the game windows (background, event, foreground, hud, etc.).
The input seems to always go to the topmost window. How could I bypass any visible window and send the controls to the one I want?

I've tried setFirstResponder(), reorderChild(), and setActive().

Another question: Since reorderChild() seems to do nothing to the way windows are organized withing a master window, is there any other way to reorganize windows after stacking them than detaching and adding them all again?

#1
06/13/2014 (1:49 pm)
By input do you mean mouse input or keyboard input?

If it's mouse input you're talking about, make sure that the GuiProfile of your GuiControls has Modal set to true;

if (!isObject(GuiModalProfile)) new GuiControlProfile (GuiModalProfile: GuiDefaultProfile)
{
    Modal = false;
};

Note that you must set this in the GuiControlProfile; setting Modal=false; directly on the object will not work for some reason.
#2
06/13/2014 (2:17 pm)
I mean mouse input (excluding the wheel). All my actual GUI windows are working fine, modally on top of everything else, but the stacked SceneWindows (even if totally transparent) don't let me click on the SceneWindow below. There is a way to circumvent this: setting the topmost SceneWindows invisible. But I would still like them to hang around while I'm editing in an arbitrary scenewindow.

The elements are organized as follows,
Canvas
-MasterWindow
--ParallaxBackWindow
--EventWindow
--ParallaxFrontWindow
--ModalGUICtrl
---GUI elements
---...
ParallaxFrontWindow steals mouse input from getting registered on the two windows below.
#3
06/13/2014 (2:39 pm)
The one thing that comes to mind would be to take the world position of the MasterWindow's mouseclick (from the OnTouchDown Method), convert it to Canvas-based coordinates and project it in the other SceneWindows.

1 - Convert %worldposition to a Canvas Position with MasterWindow.getCanvasPoint("X Y");.

2 - Convert %newCanvasPosition to the target SceneWindow's coordinates with ParallaxBackWindow.getWorldPoint("X Y");

Once you have these, you can do whatever you wish with those coordinates, even Scene.pickpoint();

There is probably a much easier way but this should work!
#4
06/13/2014 (3:00 pm)
That's a good idea, but I would still need to do that in the callback of the topmost window, since MasterWindow isn't getting any mouse input either. Maybe I'll stick with setting the visibility on and off, until I really need the foreground to be present while I'm editing. :)
#5
06/13/2014 (3:16 pm)
Hmmm. The only other suggestion I have is to make sure that your SceneWindows are set to use WindowInput events OR have an active inputlistener.

SceneWindow.setUseWindowInputEvents(true);
or
new SceneWindow(){
   UseWindowInputEvents = true;
};

For input listeners, check out the Sandbox Example. In the Sandbox module, manipulation.cs, search for SandboxInputController.