1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Merge pull request #2381 from node-red/keyboard-nav

Scroll the view with WASD/Cursor keys when nothing selected
This commit is contained in:
Nick O'Leary 2020-01-17 10:36:05 +00:00 committed by GitHub
commit 468beee045
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 0 deletions

View File

@ -44,6 +44,14 @@
"ctrl-y": "core:redo", "ctrl-y": "core:redo",
"ctrl-a": "core:select-all-nodes", "ctrl-a": "core:select-all-nodes",
"shift-?": "core:show-help", "shift-?": "core:show-help",
"w": "core:scroll-view-up",
"d": "core:scroll-view-right",
"s": "core:scroll-view-down",
"a": "core:scroll-view-left",
"shift-w": "core:step-view-up",
"shift-d": "core:step-view-right",
"shift-s": "core:step-view-down",
"shift-a": "core:step-view-left",
"up": "core:move-selection-up", "up": "core:move-selection-up",
"right": "core:move-selection-right", "right": "core:move-selection-right",
"down": "core:move-selection-down", "down": "core:move-selection-down",

View File

@ -105,6 +105,8 @@ RED.view.tools = (function() {
} }
} }
RED.view.redraw(); RED.view.redraw();
} else {
RED.view.scroll(dx*10,dy*10);
} }
} }
@ -112,6 +114,16 @@ RED.view.tools = (function() {
init: function() { init: function() {
RED.actions.add("core:align-selection-to-grid", alignToGrid); RED.actions.add("core:align-selection-to-grid", alignToGrid);
RED.actions.add("core:scroll-view-up", function() { RED.view.scroll(0,-RED.view.gridSize());});
RED.actions.add("core:scroll-view-right", function() { RED.view.scroll(RED.view.gridSize(),0);});
RED.actions.add("core:scroll-view-down", function() { RED.view.scroll(0,RED.view.gridSize());});
RED.actions.add("core:scroll-view-left", function() { RED.view.scroll(-RED.view.gridSize(),0);});
RED.actions.add("core:step-view-up", function() { RED.view.scroll(0,-5*RED.view.gridSize());});
RED.actions.add("core:step-view-right", function() { RED.view.scroll(5*RED.view.gridSize(),0);});
RED.actions.add("core:step-view-down", function() { RED.view.scroll(0,5*RED.view.gridSize());});
RED.actions.add("core:step-view-left", function() { RED.view.scroll(-5*RED.view.gridSize(),0);});
RED.actions.add("core:move-selection-up", function() { moveSelection(0,-1);}); RED.actions.add("core:move-selection-up", function() { moveSelection(0,-1);});
RED.actions.add("core:move-selection-right", function() { moveSelection(1,0);}); RED.actions.add("core:move-selection-right", function() { moveSelection(1,0);});
RED.actions.add("core:move-selection-down", function() { moveSelection(0,1);}); RED.actions.add("core:move-selection-down", function() { moveSelection(0,1);});

View File

@ -3846,6 +3846,10 @@ RED.view = (function() {
type: "compact", type: "compact",
buttons: buttons buttons: buttons
}) })
},
scroll: function(x,y) {
chart.scrollLeft(chart.scrollLeft()+x);
chart.scrollTop(chart.scrollTop()+y)
} }
}; };
})(); })();