Positioning Shortcut keys working

This commit is contained in:
Luis Fernando Molina committed 2019-10-15 13:26:31 +02:00
1 parent 24148d0d8d
commit adb506d434
3 files changed
+20 -5

No files matched your search

+6 -3
View File
@@ -186,7 +186,6 @@ function newCanvas () {
}
function onKeyDown (event) {
event.preventDefault()
if (event.altKey === true && event.code === 'ArrowUp') {
thisObject.cockpitSpace.toTop()
return
@@ -239,13 +238,17 @@ function newCanvas () {
if (event.ctrlKey === true) {
if (event.keyCode >= 65 && event.keyCode <= 90) {
event.preventDefault()
let nodeOnFocus = canvas.strategySpace.workspace.getNodeThatIsOnFocus()
let nodeUsingThisKey = canvas.strategySpace.workspace.getNodeByShortcutKey(event.key)
if (nodeOnFocus === undefined) {
/* Then we displace the whole workspace to center it at the node using this key */
nodeUsingThisKey = canvas.floatingSpace.positionAtNode(nodeUsingThisKey)
return
}
let nodeUsingThisKey = canvas.strategySpace.workspace.getNodeByShortcutKey(event.key)
/* If there is a node in focus, we try to assign the key to it. */
if (nodeUsingThisKey !== undefined) {
if (nodeUsingThisKey.id === nodeOnFocus.id) {
nodeOnFocus.payload.uiObject.shortcutKey = ''
+2 -2
View File
@@ -137,7 +137,7 @@ function newChartSpace () {
function oneScreenLeft () {
let displaceVector = {
x: -browserCanvas.width * PERCENTAGE_OF_SCREEN_FOR_DISPLACEMENT / 100,
x: browserCanvas.width * PERCENTAGE_OF_SCREEN_FOR_DISPLACEMENT / 100,
y: 0
}
@@ -146,7 +146,7 @@ function newChartSpace () {
function oneScreenRight () {
let displaceVector = {
x: +browserCanvas.width * PERCENTAGE_OF_SCREEN_FOR_DISPLACEMENT / 100,
x: -browserCanvas.width * PERCENTAGE_OF_SCREEN_FOR_DISPLACEMENT / 100,
y: 0
}
+12
View File
@@ -17,6 +17,7 @@ function newFloatingSpace () {
oneScreenDown: oneScreenDown,
oneScreenLeft: oneScreenLeft,
oneScreenRight: oneScreenRight,
positionAtNode: positionAtNode,
fitIntoVisibleArea: fitIntoVisibleArea,
isThisPointVisible: isThisPointVisible,
makeVisible: makeVisible,
@@ -135,6 +136,17 @@ function newFloatingSpace () {
thisObject.container.displace(displaceVector)
}
function positionAtNode (node) {
let position = thisObject.container.frame.frameThisPoint(node.payload.position)
let displaceVector = {
x: browserCanvas.width / 2 - position.x,
y: browserCanvas.height / 2 - position.y
}
thisObject.container.displace(displaceVector)
}
function isThisPointVisible (point) {
if (point.x > browserCanvas.width) {
return false