mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Allow the main view hold keyboard focus
This commit is contained in:
parent
81dcfecb4e
commit
fabf013714
@ -169,6 +169,7 @@ RED.palette = (function() {
|
|||||||
container:'body'
|
container:'body'
|
||||||
});
|
});
|
||||||
$(d).click(function() {
|
$(d).click(function() {
|
||||||
|
RED.view.focus();
|
||||||
var help = '<div class="node-help">'+($("script[data-help-name|='"+d.type+"']").html()||"")+"</div>";
|
var help = '<div class="node-help">'+($("script[data-help-name|='"+d.type+"']").html()||"")+"</div>";
|
||||||
$("#tab-info").html(help);
|
$("#tab-info").html(help);
|
||||||
});
|
});
|
||||||
@ -176,7 +177,8 @@ RED.palette = (function() {
|
|||||||
helper: 'clone',
|
helper: 'clone',
|
||||||
appendTo: 'body',
|
appendTo: 'body',
|
||||||
revert: true,
|
revert: true,
|
||||||
revertDuration: 50
|
revertDuration: 50,
|
||||||
|
start: function() {RED.view.focus();}
|
||||||
});
|
});
|
||||||
|
|
||||||
setLabel(nt,$(d),label);
|
setLabel(nt,$(d),label);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright 2013 IBM Corp.
|
* Copyright 2013, 2015 IBM Corp.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -60,9 +60,8 @@ RED.sidebar = (function() {
|
|||||||
$("#sidebar").width(0);
|
$("#sidebar").width(0);
|
||||||
RED.menu.setSelected("btn-sidebar",true);
|
RED.menu.setSelected("btn-sidebar",true);
|
||||||
RED.view.resize();
|
RED.view.resize();
|
||||||
|
eventHandler.emit("resize");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
sidebarSeparator.width = $("#sidebar").width();
|
sidebarSeparator.width = $("#sidebar").width();
|
||||||
},
|
},
|
||||||
drag: function(event,ui) {
|
drag: function(event,ui) {
|
||||||
@ -102,7 +101,7 @@ RED.sidebar = (function() {
|
|||||||
|
|
||||||
sidebar_tabs.resize();
|
sidebar_tabs.resize();
|
||||||
RED.view.resize();
|
RED.view.resize();
|
||||||
|
eventHandler.emit("resize");
|
||||||
},
|
},
|
||||||
stop:function(event,ui) {
|
stop:function(event,ui) {
|
||||||
RED.view.resize();
|
RED.view.resize();
|
||||||
@ -117,6 +116,7 @@ RED.sidebar = (function() {
|
|||||||
}
|
}
|
||||||
$("#sidebar-separator").css("left","auto");
|
$("#sidebar-separator").css("left","auto");
|
||||||
$("#sidebar-separator").css("right",($("#sidebar").width()+13)+"px");
|
$("#sidebar-separator").css("right",($("#sidebar").width()+13)+"px");
|
||||||
|
eventHandler.emit("resize");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -127,6 +127,7 @@ RED.sidebar = (function() {
|
|||||||
$("#main-container").removeClass("sidebar-closed");
|
$("#main-container").removeClass("sidebar-closed");
|
||||||
sidebar_tabs.resize();
|
sidebar_tabs.resize();
|
||||||
}
|
}
|
||||||
|
eventHandler.emit("resize");
|
||||||
}
|
}
|
||||||
|
|
||||||
function showSidebar(id) {
|
function showSidebar(id) {
|
||||||
@ -145,13 +146,33 @@ RED.sidebar = (function() {
|
|||||||
RED.sidebar.info.show();
|
RED.sidebar.info.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var eventHandler = (function() {
|
||||||
|
var handlers = {};
|
||||||
|
|
||||||
|
return {
|
||||||
|
on: function(evt,func) {
|
||||||
|
handlers[evt] = handlers[evt]||[];
|
||||||
|
handlers[evt].push(func);
|
||||||
|
},
|
||||||
|
emit: function(evt,arg) {
|
||||||
|
if (handlers[evt]) {
|
||||||
|
for (var i=0;i<handlers[evt].length;i++) {
|
||||||
|
handlers[evt][i](arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
init: init,
|
init: init,
|
||||||
addTab: addTab,
|
addTab: addTab,
|
||||||
removeTab: removeTab,
|
removeTab: removeTab,
|
||||||
show: showSidebar,
|
show: showSidebar,
|
||||||
containsTab: containsTab,
|
containsTab: containsTab,
|
||||||
toggleSidebar: toggleSidebar
|
toggleSidebar: toggleSidebar,
|
||||||
|
on: eventHandler.on
|
||||||
}
|
}
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
@ -67,10 +67,14 @@ RED.view = (function() {
|
|||||||
.append("svg:svg")
|
.append("svg:svg")
|
||||||
.attr("width", space_width)
|
.attr("width", space_width)
|
||||||
.attr("height", space_height)
|
.attr("height", space_height)
|
||||||
|
.attr("tabindex",1)
|
||||||
.attr("pointer-events", "all")
|
.attr("pointer-events", "all")
|
||||||
.style("cursor","crosshair");
|
.style("cursor","crosshair")
|
||||||
|
.on("mousedown", function() {
|
||||||
var vis = outer
|
this.focus();
|
||||||
|
});
|
||||||
|
|
||||||
|
var vis = outer
|
||||||
.append('svg:g')
|
.append('svg:g')
|
||||||
.on("dblclick.zoom", null)
|
.on("dblclick.zoom", null)
|
||||||
.append('svg:g')
|
.append('svg:g')
|
||||||
@ -1064,6 +1068,7 @@ RED.view = (function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function nodeMouseDown(d) {
|
function nodeMouseDown(d) {
|
||||||
|
focusView();
|
||||||
//var touch0 = d3.event;
|
//var touch0 = d3.event;
|
||||||
//var pos = [touch0.pageX,touch0.pageY];
|
//var pos = [touch0.pageX,touch0.pageY];
|
||||||
//RED.touch.radialMenu.show(d3.select(this),pos);
|
//RED.touch.radialMenu.show(d3.select(this),pos);
|
||||||
@ -1319,7 +1324,7 @@ RED.view = (function() {
|
|||||||
.attr("height",node_height-12)
|
.attr("height",node_height-12)
|
||||||
.attr("fill",function(d) { return d._def.color;})
|
.attr("fill",function(d) { return d._def.color;})
|
||||||
.attr("cursor","pointer")
|
.attr("cursor","pointer")
|
||||||
.on("mousedown",function(d) {if (!lasso) { d3.select(this).attr("fill-opacity",0.2);d3.event.preventDefault(); d3.event.stopPropagation();}})
|
.on("mousedown",function(d) {if (!lasso) {focusView();d3.select(this).attr("fill-opacity",0.2);d3.event.preventDefault(); d3.event.stopPropagation();}})
|
||||||
.on("mouseup",function(d) {if (!lasso) { d3.select(this).attr("fill-opacity",0.4);d3.event.preventDefault();d3.event.stopPropagation();}})
|
.on("mouseup",function(d) {if (!lasso) { d3.select(this).attr("fill-opacity",0.4);d3.event.preventDefault();d3.event.stopPropagation();}})
|
||||||
.on("mouseover",function(d) {if (!lasso) { d3.select(this).attr("fill-opacity",0.4);}})
|
.on("mouseover",function(d) {if (!lasso) { d3.select(this).attr("fill-opacity",0.4);}})
|
||||||
.on("mouseout",function(d) {if (!lasso) {
|
.on("mouseout",function(d) {if (!lasso) {
|
||||||
@ -1656,6 +1661,7 @@ RED.view = (function() {
|
|||||||
selected_link = mousedown_link;
|
selected_link = mousedown_link;
|
||||||
updateSelection();
|
updateSelection();
|
||||||
redraw();
|
redraw();
|
||||||
|
focusView();
|
||||||
d3.event.stopPropagation();
|
d3.event.stopPropagation();
|
||||||
})
|
})
|
||||||
.on("touchstart",function(d) {
|
.on("touchstart",function(d) {
|
||||||
@ -1664,6 +1670,7 @@ RED.view = (function() {
|
|||||||
selected_link = mousedown_link;
|
selected_link = mousedown_link;
|
||||||
updateSelection();
|
updateSelection();
|
||||||
redraw();
|
redraw();
|
||||||
|
focusView();
|
||||||
d3.event.stopPropagation();
|
d3.event.stopPropagation();
|
||||||
});
|
});
|
||||||
l.append("svg:path").attr("class","link_outline link_path");
|
l.append("svg:path").attr("class","link_outline link_path");
|
||||||
@ -1733,6 +1740,10 @@ RED.view = (function() {
|
|||||||
$("#btn-deploy").addClass("disabled");
|
$("#btn-deploy").addClass("disabled");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function focusView() {
|
||||||
|
$("#chart svg").focus();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Imports a new collection of nodes from a JSON String.
|
* Imports a new collection of nodes from a JSON String.
|
||||||
@ -2058,6 +2069,7 @@ RED.view = (function() {
|
|||||||
RED.keyboard.remove(/* ESCAPE */ 27);
|
RED.keyboard.remove(/* ESCAPE */ 27);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$('#chart').on("dragenter",function(event) {
|
$('#chart').on("dragenter",function(event) {
|
||||||
if ($.inArray("text/plain",event.originalEvent.dataTransfer.types) != -1) {
|
if ($.inArray("text/plain",event.originalEvent.dataTransfer.types) != -1) {
|
||||||
$("#dropTarget").css({display:'table'});
|
$("#dropTarget").css({display:'table'});
|
||||||
@ -2119,6 +2131,7 @@ RED.view = (function() {
|
|||||||
setDirty(d);
|
setDirty(d);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
focus: focusView,
|
||||||
importNodes: importNodes,
|
importNodes: importNodes,
|
||||||
resize: function() {
|
resize: function() {
|
||||||
workspace_tabs.resize();
|
workspace_tabs.resize();
|
||||||
@ -2130,7 +2143,7 @@ RED.view = (function() {
|
|||||||
redraw();
|
redraw();
|
||||||
},
|
},
|
||||||
calculateTextWidth: calculateTextWidth,
|
calculateTextWidth: calculateTextWidth,
|
||||||
|
|
||||||
//TODO: should these move to an import/export module?
|
//TODO: should these move to an import/export module?
|
||||||
showImportNodesDialog: showImportNodesDialog,
|
showImportNodesDialog: showImportNodesDialog,
|
||||||
showExportNodesDialog: showExportNodesDialog,
|
showExportNodesDialog: showExportNodesDialog,
|
||||||
|
@ -259,7 +259,9 @@ span.deploy-button-group.open > #btn-deploy.disabled + a {
|
|||||||
left:0px;
|
left:0px;
|
||||||
right:0px;
|
right:0px;
|
||||||
}
|
}
|
||||||
|
#chart svg:focus {
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
#workspace-toolbar {
|
#workspace-toolbar {
|
||||||
display: none;
|
display: none;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user