mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-13 03:33:48 +00:00
Adds a flag to the guiGameListMenuCtrl to allow consuming of key input events. This allows for overriding other active keybinds that may be in play when a menu is active.
This commit is contained in:
parent
d8e82d1ba6
commit
bca972ae24
3 changed files with 25 additions and 3 deletions
|
|
@ -37,7 +37,8 @@ GuiGameListMenuCtrl::GuiGameListMenuCtrl()
|
|||
: mSelected(NO_ROW),
|
||||
mDebugRender(false),
|
||||
mHighlighted(NO_ROW),
|
||||
mCallbackOnInputs(false)
|
||||
mCallbackOnInputs(false),
|
||||
mConsumeKeyInputEvents(false)
|
||||
{
|
||||
VECTOR_SET_ASSOCIATION(mRows);
|
||||
|
||||
|
|
@ -822,6 +823,8 @@ bool GuiGameListMenuCtrl::onInputEvent(const InputEventInfo& event)
|
|||
if (!ActionMap::getDeviceName(event.deviceType, event.deviceInst, deviceString))
|
||||
return false;
|
||||
|
||||
StringTableEntry deviceStringEntry = StringTable->insert(deviceString);
|
||||
|
||||
if (event.action == SI_MAKE || event.action == SI_BREAK)
|
||||
{
|
||||
bool isModifier = false;
|
||||
|
|
@ -847,12 +850,25 @@ bool GuiGameListMenuCtrl::onInputEvent(const InputEventInfo& event)
|
|||
if (!ActionMap::getKeyString(event.objInst, keyString))
|
||||
return false;
|
||||
|
||||
onInputEvent_callback(deviceString, keyString, state);
|
||||
onInputEvent_callback(deviceStringEntry, keyString, state);
|
||||
|
||||
if (mConsumeKeyInputEvents)
|
||||
{
|
||||
if(deviceStringEntry == StringTable->insert("keyboard"))
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
const char* actionString = ActionMap::buildActionString(&event);
|
||||
onInputEvent_callback(deviceString, actionString, state);
|
||||
onInputEvent_callback(deviceStringEntry, actionString, state);
|
||||
|
||||
if (mConsumeKeyInputEvents)
|
||||
{
|
||||
if (deviceStringEntry == StringTable->insert("keyboard"))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (event.objType == SI_AXIS || event.objType == SI_INT || event.objType == SI_FLOAT)
|
||||
|
|
@ -1401,6 +1417,10 @@ void GuiGameListMenuCtrl::initPersistFields()
|
|||
addField("callbackOnInputs", TypeBool, Offset(mCallbackOnInputs, GuiGameListMenuCtrl),
|
||||
"Script callback when any inputs are detected, even if they aren't the regular 4 face buttons. Useful for secondary/speciality handling of menu navigation.");
|
||||
|
||||
addField("consumeKeyInputEvents", TypeBool, Offset(mConsumeKeyInputEvents, GuiGameListMenuCtrl),
|
||||
"When callbackOnInputs is active, this indicates if the input event should be consumed, or allowed 'through' to let other things respond to the event as well.");
|
||||
|
||||
|
||||
Parent::initPersistFields();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue