From 8e0a47bf0a81ec56dc503facdcfbf1c32e43c2b6 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sun, 1 Dec 2019 13:17:32 +0100 Subject: [PATCH] Divider handling with keyboard improved: https://github.com/Superalgos/DesktopApp/issues/112 --- Canvas.js | 27 +++++++++++++++++++++------ DesignerSpace/Workspace/Workspace.js | 8 +++++--- Spaces/CockpitSpace.js | 21 +++++++++++++++++++++ 3 files changed, 47 insertions(+), 9 deletions(-) diff --git a/Canvas.js b/Canvas.js index c548081b9..2b3e8f95f 100644 --- a/Canvas.js +++ b/Canvas.js @@ -216,22 +216,37 @@ function newCanvas () { } } - if (event.altKey === true && event.code === 'ArrowUp') { + if (event.shiftKey === true && event.altKey === true && event.ctrlKey === true && event.code === 'ArrowUp') { thisObject.cockpitSpace.toTop() return } - if (event.altKey === true && event.code === 'ArrowDown') { + if (event.shiftKey === true && event.altKey === true && event.ctrlKey && event.code === 'ArrowDown') { thisObject.cockpitSpace.toBottom() return } - if (event.shiftKey === true && event.code === 'ArrowLeft') { + if (event.shiftKey === true && event.altKey === true && event.ctrlKey && event.code === 'ArrowLeft' || event.altKey === true && event.code === 'ArrowRight') { + thisObject.cockpitSpace.toMiddle() + return + } + + if (event.shiftKey === true && event.ctrlKey && event.code === 'ArrowUp') { + thisObject.cockpitSpace.moveUp() + return + } + + if (event.shiftKey === true && event.ctrlKey && event.code === 'ArrowDown') { + thisObject.cockpitSpace.moveDown() + return + } + + if (event.shiftKey === true && event.ctrlKey === false && event.code === 'ArrowLeft') { canvas.chartSpace.oneScreenLeft() return } - if (event.shiftKey === true && event.code === 'ArrowRight') { + if (event.shiftKey === true && event.ctrlKey === false && event.code === 'ArrowRight') { canvas.chartSpace.oneScreenRight() return } @@ -246,7 +261,7 @@ function newCanvas () { return } - if ((event.ctrlKey === true || event.metaKey === true) && event.code === 'ArrowLeft') { + if ((event.ctrlKey === true || event.metaKey === true) && event.shiftKey === false && event.code === 'ArrowLeft') { let displaceVector = canvas.floatingSpace.oneScreenLeft() dragVector.downX = dragVector.downX + displaceVector.x dragVector.downY = dragVector.downY + displaceVector.y @@ -254,7 +269,7 @@ function newCanvas () { return } - if ((event.ctrlKey === true || event.metaKey === true) && event.code === 'ArrowRight') { + if ((event.ctrlKey === true || event.metaKey === true) && event.shiftKey === false && event.code === 'ArrowRight') { let displaceVector = canvas.floatingSpace.oneScreenRight() dragVector.downX = dragVector.downX + displaceVector.x dragVector.downY = dragVector.downY + displaceVector.y diff --git a/DesignerSpace/Workspace/Workspace.js b/DesignerSpace/Workspace/Workspace.js index 2b150a4e8..f900426ef 100644 --- a/DesignerSpace/Workspace/Workspace.js +++ b/DesignerSpace/Workspace/Workspace.js @@ -160,9 +160,11 @@ function newWorkspace () { let taskManager = networkNode.taskManagers[i] for (k = 0; k < taskManager.tasks.length; k++) { let task = taskManager.tasks[k] - if (task.bot.type === 'Trading Bot Instance') { - if (task.bot.payload.floatingObject.isCollapsed !== true) { - tradingBotInstances.push(task.bot) + if (task.bot !== undefined) { + if (task.bot.type === 'Trading Bot Instance') { + if (task.bot.payload.floatingObject.isCollapsed !== true) { + tradingBotInstances.push(task.bot) + } } } } diff --git a/Spaces/CockpitSpace.js b/Spaces/CockpitSpace.js index 453d5e779..39c2f2a0a 100644 --- a/Spaces/CockpitSpace.js +++ b/Spaces/CockpitSpace.js @@ -9,6 +9,9 @@ fullscreen: undefined, toTop: toTop, toBottom: toBottom, + toMiddle: toMiddle, + moveUp: moveUp, + moveDown: moveDown, draw: draw, physics: physics, getContainer: getContainer, @@ -87,6 +90,24 @@ thisObject.container.frame.position.y = browserCanvas.height - COCKPIT_SPACE_HEIGHT } + function toMiddle () { + thisObject.container.frame.position.y = browserCanvas.height / 2 - COCKPIT_SPACE_HEIGHT + } + + function moveUp () { + thisObject.container.frame.position.y = thisObject.container.frame.position.y - browserCanvas.height / 10 + if (thisObject.container.frame.position.y < 0) { + thisObject.container.frame.position.y = 0 + } + } + + function moveDown () { + thisObject.container.frame.position.y = thisObject.container.frame.position.y + browserCanvas.height / 10 + if (thisObject.container.frame.position.y > browserCanvas.height - COCKPIT_SPACE_HEIGHT) { + thisObject.container.frame.position.y = browserCanvas.height - COCKPIT_SPACE_HEIGHT + } + } + function physics () { thisObjectPhysics() childrenPhysics()