mirror of
				https://github.com/node-red/node-red.git
				synced 2025-03-01 10:36:34 +00: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:
		| @@ -44,6 +44,14 @@ | ||||
|         "ctrl-y": "core:redo", | ||||
|         "ctrl-a": "core:select-all-nodes", | ||||
|         "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", | ||||
|         "right": "core:move-selection-right", | ||||
|         "down": "core:move-selection-down", | ||||
|   | ||||
| @@ -105,6 +105,8 @@ RED.view.tools = (function() { | ||||
|                 } | ||||
|             } | ||||
|             RED.view.redraw(); | ||||
|         } else { | ||||
|             RED.view.scroll(dx*10,dy*10); | ||||
|         } | ||||
|     } | ||||
|  | ||||
| @@ -112,6 +114,16 @@ RED.view.tools = (function() { | ||||
|         init: function() { | ||||
|             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-right", function() { moveSelection(1,0);}); | ||||
|             RED.actions.add("core:move-selection-down", function() { moveSelection(0,1);}); | ||||
|   | ||||
| @@ -3846,6 +3846,10 @@ RED.view = (function() { | ||||
|                 type: "compact", | ||||
|                 buttons: buttons | ||||
|             }) | ||||
|         }, | ||||
|         scroll: function(x,y) { | ||||
|             chart.scrollLeft(chart.scrollLeft()+x); | ||||
|             chart.scrollTop(chart.scrollTop()+y) | ||||
|         } | ||||
|     }; | ||||
| })(); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user