Game Development Community

InputManager not work with multiple scenewindows?

by Christian · in Torque 2D Beginner · 03/01/2014 (10:29 pm) · 9 replies

I just noticed that all the InputManager:: functions do not work when other scenewindows are used. I'd guess because the OnTouchDown click is clicking on the secondary scenewindow and never makes it to the original.

Is there a way to counter this?

#1
03/02/2014 (6:02 am)
Most event callbacks start here:

function SceneWindow::onTouchDown

So you are saying this is only called once on a single SceneWindow when you perform a click/touch? Both have input events enabled and are modal?
#2
03/02/2014 (10:21 am)
The main window creates an InputManager:

new ScriptObject(InputManager);
mySceneWindow.addInputListener(InputManager);
//variable that denotes the last sprite touched  
$activeSprite = null;
InputManager.Init_controls();

function InputManager::onTouchDown(%this, %touchId, %worldposition)

When I add InputManager to the non-main windows they can receive click events, but the new windows block the objects on the main window from receiving them.
secondaryWindow.addInputListener(InputManager);

I did try making them modal as well
new SceneWindow(secondaryWindow)
   {
     Profile = GuiDefaultProfile;
     Position = "0 0";
     Extent = "900 603"; //64 99
     Modal = true;
   };

So basically with a secondaryWindow on top of the main 'sceneWindow', the objects on 'sceneWindow' do not receive any input clicks.
#3
03/02/2014 (2:20 pm)
Don't know much about T2D, use T3D, but would it be possible to create a secondary input manager object and just use that for the second window. That way each sceneWindow has its own manager instead of sharing objects?

Dunno if that will resolve anything or not.
#4
03/02/2014 (3:07 pm)
That may be possible, but the first window objects do not receive clicks once the 2nd window is on top of it.
#5
03/02/2014 (3:35 pm)
How about remove the input listener from the first scene when you switch to the 2nd, that way only 1 is active at a time.
#6
03/02/2014 (3:45 pm)
Tried it with only 1 active, but still couldn't reach the objects in the original window.
#7
03/02/2014 (3:47 pm)
are you trying to do some sort of minimap or something? If that is the case, it might not be the best to do it through script, rather do a render to texture via engine/c++.
#8
03/02/2014 (3:54 pm)
Yeah, I have 3 windows, the main, the minimap and the other is for general GUI such as text. I was more experienced with T3D as well, where UI was super easy.
#9
03/04/2014 (3:13 am)
I just did some tests with the MultiWindowToy. Basically I added Sandbox.InputController as a listener to SandboxWindow2 and turned off the linear and angular velocity of the gems. Since this toy uses pull mode by default, I could click and drag a gem in either window and the gem would move in the scene as expected.

Sounds like there is an issue in your scripts.