From ab52593899f6cbe6805cddb9d8e57d0ba0e27946 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sun, 15 Mar 2020 18:51:24 +0100 Subject: [PATCH] new toggles --- Canvas.js | 15 ++++++++++----- FloatingSpace/UiObject.js | 1 + Spaces/FloatingSpace.js | 11 ++++++++++- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/Canvas.js b/Canvas.js index 6447bb4ac..f86a717cf 100644 --- a/Canvas.js +++ b/Canvas.js @@ -246,6 +246,9 @@ function newCanvas () { } function onKeyDown (event) { + /* From here we prevent the default behaviour */ + event.preventDefault() + thisObject.mouse.event = event thisObject.mouse.action = 'key down' @@ -256,16 +259,21 @@ function newCanvas () { canvas.floatingSpace.exitMapMode() } - if (event.key === 'M' || event.key === 'm') { + if (event.shiftKey === true && (event.ctrlKey === true || event.metaKey === true) && (event.key === 'M' || event.key === 'm')) { canvas.floatingSpace.toggleMapMode() return } - if (event.key === 'R' || event.key === 'r') { + if (event.shiftKey === true && (event.ctrlKey === true || event.metaKey === true) && (event.key === 'R' || event.key === 'r')) { canvas.floatingSpace.toggleDrawReferenceLines() return } + if (event.shiftKey === true && (event.ctrlKey === true || event.metaKey === true) && (event.key === 'C' || event.key === 'c')) { + canvas.floatingSpace.toggleDrawChainLines() + return + } + let nodeOnFocus = canvas.designSpace.workspace.getNodeThatIsOnFocus() if (nodeOnFocus !== undefined) { if (nodeOnFocus.payload.uiObject.codeEditor !== undefined) { @@ -392,9 +400,6 @@ function newCanvas () { if ((event.ctrlKey === true || event.metaKey === true) && event.altKey === true) { if ((event.keyCode >= 48 && event.keyCode <= 57) || (event.keyCode >= 65 && event.keyCode <= 90)) { - /* From here we prevent the default behaviour */ - event.preventDefault() - let nodeUsingThisKey = canvas.designSpace.workspace.getNodeByShortcutKey(event.key) if (nodeOnFocus === undefined && nodeUsingThisKey !== undefined) { diff --git a/FloatingSpace/UiObject.js b/FloatingSpace/UiObject.js index 41c03c6dd..0b203c3ad 100644 --- a/FloatingSpace/UiObject.js +++ b/FloatingSpace/UiObject.js @@ -945,6 +945,7 @@ function newUiObject () { } function drawChainLine () { + if (canvas.floatingSpace.drawChainLines === false) { return } if (thisObject.payload.chainParent === undefined) { return } let targetPoint = { diff --git a/Spaces/FloatingSpace.js b/Spaces/FloatingSpace.js index 353491361..bde841e0e 100644 --- a/Spaces/FloatingSpace.js +++ b/Spaces/FloatingSpace.js @@ -13,6 +13,8 @@ function newFloatingSpace () { container: undefined, inMapMode: false, drawReferenceLines: true, + drawChainLines: true, + toggleDrawChainLines: toggleDrawChainLines, toggleDrawReferenceLines: toggleDrawReferenceLines, toggleMapMode: toggleMapMode, enterMapMode: enterMapMode, @@ -91,6 +93,14 @@ function newFloatingSpace () { } } + function toggleDrawChainLines () { + if (thisObject.drawChainLines === true) { + thisObject.drawChainLines = false + } else { + thisObject.drawChainLines = true + } + } + function transformPointToMap (point) { let returnPoint = { x: point.x - thisObject.container.frame.position.x, @@ -395,4 +405,3 @@ function newFloatingSpace () { browserCanvasContext.fill() } } -