mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-13 03:33:48 +00:00
Fixes design oversight where the general game menu keybind was being overridden due to order of operations issues with an offscreen canvas demoing the options menu
Fixed via several solutions to prevent issue from cropping up again. Firstly, Adjusted behavior script-side so game menu keybind is pushed with the PlayGUI since almost every single game will use the game menu Secondly, added logic so that the guiInputCtrl, when going to push an ActionMap(if it has one) will check if it's root canvas is active. Thirdly, to allow guiInputCtrls to respond to a canvas becoming active, such as a GUi-on-Material surface displaying a menu and it's activated, an offscreen canvas becoming active now trips a signal that guiInputCtrl listens for.
This commit is contained in:
parent
07c67f2935
commit
970aba9766
6 changed files with 67 additions and 4 deletions
|
|
@ -23,6 +23,7 @@
|
|||
#include "gui/utility/guiInputCtrl.h"
|
||||
#include "sim/actionMap.h"
|
||||
#include "console/engineAPI.h"
|
||||
#include "gui/core/guiCanvas.h"
|
||||
|
||||
IMPLEMENT_CONOBJECT(GuiInputCtrl);
|
||||
|
||||
|
|
@ -88,6 +89,13 @@ void GuiInputCtrl::initPersistFields()
|
|||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
bool GuiInputCtrl::onAdd()
|
||||
{
|
||||
if (!Parent::onAdd())
|
||||
return false;
|
||||
|
||||
GuiCanvas::getCanvasSetActiveSignal().notify(this, &GuiInputCtrl::handleCanvasSetActive);
|
||||
}
|
||||
|
||||
bool GuiInputCtrl::onWake()
|
||||
{
|
||||
|
|
@ -108,8 +116,11 @@ bool GuiInputCtrl::onWake()
|
|||
|
||||
if(mActionmap != nullptr)
|
||||
{
|
||||
SimSet* actionMapSet = Sim::getActiveActionMapSet();
|
||||
actionMapSet->pushObject(mActionmap);
|
||||
if (getRoot()->isActive())
|
||||
{
|
||||
SimSet* actionMapSet = Sim::getActiveActionMapSet();
|
||||
actionMapSet->pushObject(mActionmap);
|
||||
}
|
||||
}
|
||||
|
||||
setFirstResponder();
|
||||
|
|
@ -152,6 +163,25 @@ void GuiInputCtrl::setActive(bool value)
|
|||
|
||||
}
|
||||
|
||||
void GuiInputCtrl::handleCanvasSetActive(GuiCanvas* canvas, bool isActive)
|
||||
{
|
||||
if (mActionmap == nullptr)
|
||||
return;
|
||||
|
||||
if (getRoot() == canvas)
|
||||
{
|
||||
if (isActive)
|
||||
{
|
||||
SimSet* actionMapSet = Sim::getActiveActionMapSet();
|
||||
actionMapSet->pushObject(mActionmap);
|
||||
}
|
||||
else
|
||||
{
|
||||
SimSet* actionMapSet = Sim::getActiveActionMapSet();
|
||||
actionMapSet->removeObject(mActionmap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
static bool isModifierKey( U16 keyCode )
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue