Fix for bound actions occuring when Alt+Tab and Shift+Alt+Tab are pressed
by Todd D. Degani · 05/20/2005 (4:20 pm) · 5 comments
There is an issue when processAction looks for a command bound to a key that it also looks for a command bound to the same key without modifiers. In Windows, if you have an action bound to tab, such as toggle first person view, and press alt+tab or shift+alt+tab you will navigate windows as well as execute the command bound to tab.
This fix changes the behavior of processAction so that if the tab key is pressed it will only look at it with all the modifiers. I do not think this is an issue for other OS's so I made it Windows specific.
In the function ActionMap::processAction of actionMap.cc at the beginning of the function change:
to
This fix changes the behavior of processAction so that if the tab key is pressed it will only look at it with all the modifiers. I do not think this is an issue for other OS's so I made it Windows specific.
In the function ActionMap::processAction of actionMap.cc at the beginning of the function change:
if (pEvent->action == SI_MAKE) {
const Node* pNode = findNode(pEvent->deviceType, pEvent->deviceInst,
pEvent->modifier, pEvent->objInst);
if (pNode == NULL) {
// Check to see if we clear the modifiers, do we find an action?
if (pEvent->modifier != 0)
pNode = findNode(pEvent->deviceType, pEvent->deviceInst,
0, pEvent->objInst);
if (pNode == NULL)
return false;
}to
if (pEvent->action == SI_MAKE) {
const Node* pNode = findNode(pEvent->deviceType, pEvent->deviceInst,
pEvent->modifier, pEvent->objInst);
if (pNode == NULL)
{
// Check to see if we clear the modifiers, do we find an action?
// TDD - We do not allow looking for actions without the modifiers
// if the key pressed is TAB. This is to stop actions that are bound
// to tab from occuring when ALT+TAB and SHIFT+ALT+TAB happen.
// I do not think this is an issue for other OS's so making it
// Windows specific.
#ifdef TORQUE_OS_WIN32
if (pEvent->modifier != 0 && pEvent->objInst != KEY_TAB)
#else
if (pEvent->modifier != 0)
#endif
// ---------------
{
pNode = findNode(pEvent->deviceType, pEvent->deviceInst,
0, pEvent->objInst);
}
if (pNode == NULL)
return false;
}About the author
#2
B--
05/21/2005 (9:39 am)
Thanks for posting this as resource! I remember reading (I think it was your thread) about this problem. Great job!B--
#3
01/18/2006 (8:23 pm)
Did this end up in TGE 1.4?
#4
1) This problem occurs on Linux as well (but not Mac). Solution is easy: simply OR the existing define with defined(TORQUE_OS_LINUX).
2) This will also consume (SHIFT|CTRL|SHIFT-CTRL|ALT-CTRL|ALT-CTRL-SHIFT) Tab key combos instead of sending them to Tab like the rest of the keys. This is not likely a huge issue for most folks but it does cause the behavior of this one key to differ from all the others.
3) If there is a script solution, especially an easy one, I prefer it to altering the engine.
In the end, it's up to you. Either works.
example:
actionMap.bind(keyboard, "alt tab", doNothingFunction);
actionMap.bind(keyboard, "alt-shift tab", doNothingFunction);
11/28/2007 (12:12 pm)
Another option does not involve modifying the engine code. Simply add key bindings to capture these keystrokes. I prefer this solution to engine solution for several reasons:1) This problem occurs on Linux as well (but not Mac). Solution is easy: simply OR the existing define with defined(TORQUE_OS_LINUX).
2) This will also consume (SHIFT|CTRL|SHIFT-CTRL|ALT-CTRL|ALT-CTRL-SHIFT) Tab key combos instead of sending them to Tab like the rest of the keys. This is not likely a huge issue for most folks but it does cause the behavior of this one key to differ from all the others.
3) If there is a script solution, especially an easy one, I prefer it to altering the engine.
In the end, it's up to you. Either works.
example:
actionMap.bind(keyboard, "alt tab", doNothingFunction);
actionMap.bind(keyboard, "alt-shift tab", doNothingFunction);
#5
actionMap.bind(keyboard, "alt tab", printSomething);
while any other bind method do work like:
actionMap.bind(keyboard, "alt a", printSomething); will print something.
Any ideas how to fix that?
Thanks,
Eyal.
06/05/2008 (12:28 pm)
For some reason alt tab completely ingores the actionMapactionMap.bind(keyboard, "alt tab", printSomething);
while any other bind method do work like:
actionMap.bind(keyboard, "alt a", printSomething); will print something.
Any ideas how to fix that?
Thanks,
Eyal.

Torque Owner Adrian Walters