From 01152a729df6f439f0046475e844fada60d64512 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 10 Dec 2019 11:42:24 +0100 Subject: [PATCH] Focus and Shortcut keys working with the APP Schema --- .../Workspace/FunctionLibraries/OnFocus.js | 45 +++++++++++++++++++ .../FunctionLibraries/ShortcutKeys.js | 45 +++++++++++++++++++ 2 files changed, 90 insertions(+) diff --git a/DesignerSpace/Workspace/FunctionLibraries/OnFocus.js b/DesignerSpace/Workspace/FunctionLibraries/OnFocus.js index 353eb3723..902c89d31 100644 --- a/DesignerSpace/Workspace/FunctionLibraries/OnFocus.js +++ b/DesignerSpace/Workspace/FunctionLibraries/OnFocus.js @@ -1061,6 +1061,10 @@ function newOnFocus () { if (child !== undefined) { return child } + child = getNodeThatIsOnFocus(node.shapes) + if (child !== undefined) { + return child + } for (let m = 0; m < node.panels.length; m++) { child = getNodeThatIsOnFocus(node.panels[m]) if (child !== undefined) { @@ -1085,6 +1089,47 @@ function newOnFocus () { return } } + default: { + let nodeDefinition = APP_SCHEMA_MAP.get(node.type) + if (nodeDefinition !== undefined) { + /* First we ask the question to ourself */ + if (node.payload.uiObject.isOnFocus === true) { + return node + } + + /* Then we check all of its own children nodes. */ + if (nodeDefinition.properties !== undefined) { + for (let i = 0; i < nodeDefinition.properties.length; i++) { + let property = nodeDefinition.properties[i] + + switch (property.type) { + case 'node': { + if (node[property.name] !== undefined) { + let child + child = getNodeThatIsOnFocus(node[property.name]) + if (child !== undefined) { + return child + } + } + } + break + case 'array': { + let nodePropertyArray = node[property.name] + if (nodePropertyArray !== undefined) { + for (let m = 0; m < nodePropertyArray.length; m++) { + child = getNodeThatIsOnFocus(nodePropertyArray[m]) + if (child !== undefined) { + return child + } + } + } + } + break + } + } + } + } + } } } } diff --git a/DesignerSpace/Workspace/FunctionLibraries/ShortcutKeys.js b/DesignerSpace/Workspace/FunctionLibraries/ShortcutKeys.js index 31e3c7070..891e81e9b 100644 --- a/DesignerSpace/Workspace/FunctionLibraries/ShortcutKeys.js +++ b/DesignerSpace/Workspace/FunctionLibraries/ShortcutKeys.js @@ -1038,6 +1038,10 @@ function newShortcutKeys () { if (child !== undefined) { return child } + child = getNodeByShortcutKey(node.shapes, searchingKey) + if (child !== undefined) { + return child + } for (let m = 0; m < node.panels.length; m++) { child = getNodeByShortcutKey(node.panels[m], searchingKey) if (child !== undefined) { @@ -1063,6 +1067,47 @@ function newShortcutKeys () { } } + default: { + let nodeDefinition = APP_SCHEMA_MAP.get(node.type) + if (nodeDefinition !== undefined) { + /* Check Self first */ + if (node.payload.uiObject.shortcutKey === searchingKey) { + return node + } + + /* Check all of its own children nodes. */ + if (nodeDefinition.properties !== undefined) { + for (let i = 0; i < nodeDefinition.properties.length; i++) { + let property = nodeDefinition.properties[i] + + switch (property.type) { + case 'node': { + if (node[property.name] !== undefined) { + let child + child = getNodeByShortcutKey(node[property.name], searchingKey) + if (child !== undefined) { + return child + } + } + } + break + case 'array': { + let nodePropertyArray = node[property.name] + if (nodePropertyArray !== undefined) { + for (let m = 0; m < nodePropertyArray.length; m++) { + child = getNodeByShortcutKey(nodePropertyArray[m], searchingKey) + if (child !== undefined) { + return child + } + } + } + } + break + } + } + } + } + } } } }