Api: Find the current focused object from global instead of app object when handling key presses

Should better handle apps admin where the focused object could be from a different app
This commit is contained in:
nathangray 2020-05-20 10:31:32 -06:00
parent 6a425ac935
commit 3626679408

View File

@ -267,10 +267,11 @@ function egw_keyHandler(_keyCode, _shift, _ctrl, _alt) {
// Get the object manager and fetch the container of the currently // Get the object manager and fetch the container of the currently
// focused object // focused object
var focusedObject = egw_globalObjectManager.getFocusedObject();
var appMgr = egw_getAppObjectManager(false); var appMgr = egw_getAppObjectManager(false);
if (appMgr) if (appMgr && !focusedObject)
{ {
var focusedObject = appMgr.getFocusedObject(); focusedObject = appMgr.getFocusedObject();
if (!focusedObject) if (!focusedObject)
{ {
@ -296,34 +297,33 @@ function egw_keyHandler(_keyCode, _shift, _ctrl, _alt) {
focusedObject = cntr.children[0]; focusedObject = cntr.children[0];
} }
} }
}
if (focusedObject)
{
// Handle the default keys (arrow_up, down etc.)
var cntr = focusedObject.getContainerRoot();
var handled = false;
if (focusedObject) if (cntr)
{ {
handled = cntr.handleKeyPress(_keyCode, _shift, _ctrl, _alt);
// Handle the default keys (arrow_up, down etc.)
var cntr = focusedObject.getContainerRoot();
var handled = false;
if (cntr)
{
handled = cntr.handleKeyPress(_keyCode, _shift, _ctrl, _alt);
}
// Execute the egw_popup key handler of the focused object
if (!handled) {
return focusedObject.executeActionImplementation(
{
"keyEvent": {
"keyCode": _keyCode,
"shift": _shift,
"ctrl": _ctrl,
"alt": _alt
}
}, "popup", EGW_AO_EXEC_SELECTED);
}
return handled;
} }
// Execute the egw_popup key handler of the focused object
if (!handled)
{
return focusedObject.executeActionImplementation(
{
"keyEvent": {
"keyCode": _keyCode,
"shift": _shift,
"ctrl": _ctrl,
"alt": _alt
}
}, "popup", EGW_AO_EXEC_SELECTED);
}
return handled;
} }
return false; return false;