mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
add fast entry via keyboard for string of nodes
This commit is contained in:
parent
7a6e1fe566
commit
766ccf85c2
@ -48,7 +48,7 @@ RED.typeSearch = (function() {
|
||||
//shade = $('<div>',{class:"red-ui-type-search-shade"}).appendTo("#main-container");
|
||||
dialog = $("<div>",{id:"red-ui-type-search",class:"red-ui-search red-ui-type-search"}).appendTo("#main-container");
|
||||
var searchDiv = $("<div>",{class:"red-ui-search-container"}).appendTo(dialog);
|
||||
searchInput = $('<input type="text">').attr("placeholder",RED._("search.addNode")).appendTo(searchDiv).searchBox({
|
||||
searchInput = $('<input type="text" id="red-ui-type-search-input">').attr("placeholder",RED._("search.addNode")).appendTo(searchDiv).searchBox({
|
||||
delay: 50,
|
||||
change: function() {
|
||||
search($(this).val());
|
||||
@ -79,6 +79,17 @@ RED.typeSearch = (function() {
|
||||
$(children[selected]).addClass('selected');
|
||||
ensureSelectedIsVisible();
|
||||
evt.preventDefault();
|
||||
} else if ((evt.metaKey || evt.ctrlKey) && evt.keyCode === 13 ) {
|
||||
// (ctrl or cmd) and enter
|
||||
var index = Math.max(0,selected);
|
||||
if (index < children.length) {
|
||||
var n = $(children[index]).find(".red-ui-editableList-item-content").data('data');
|
||||
typesUsed[n.type] = Date.now();
|
||||
if (n.def.outputs === 0) { confirm(n); }
|
||||
else { addCallback(n.type,true); }
|
||||
$("#red-ui-type-search-input").val("");
|
||||
}
|
||||
evt.preventDefault();
|
||||
} else if (evt.keyCode === 13) {
|
||||
// Enter
|
||||
var index = Math.max(0,selected);
|
||||
@ -202,7 +213,7 @@ RED.typeSearch = (function() {
|
||||
}
|
||||
refreshTypeList(opts);
|
||||
addCallback = opts.add;
|
||||
closeCallback = opts.close;
|
||||
cancelCallback = opts.cancel;
|
||||
RED.events.emit("type-search:open");
|
||||
//shade.show();
|
||||
dialog.css({left:opts.x+"px",top:opts.y+"px"}).show();
|
||||
@ -230,7 +241,6 @@ RED.typeSearch = (function() {
|
||||
$(document).off('click.type-search');
|
||||
}
|
||||
}
|
||||
|
||||
function getTypeLabel(type, def) {
|
||||
var label = type;
|
||||
if (typeof def.paletteLabel !== "undefined") {
|
||||
|
@ -650,10 +650,8 @@ RED.view = (function() {
|
||||
mouse_mode = RED.state.PANNING;
|
||||
mouse_position = [d3.event.pageX,d3.event.pageY]
|
||||
scroll_position = [chart.scrollLeft(),chart.scrollTop()];
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mousedown_node && !mousedown_link) {
|
||||
selected_link = null;
|
||||
updateSelection();
|
||||
@ -692,17 +690,21 @@ RED.view = (function() {
|
||||
cancel: function() {
|
||||
quickAddActive = false;
|
||||
resetMouseVars();
|
||||
updateSelection();
|
||||
hideDragLines();
|
||||
redraw();
|
||||
},
|
||||
add: function(type) {
|
||||
add: function(type,auto) {
|
||||
quickAddActive = false;
|
||||
if (auto === true) { mouse_mode = RED.state.QUICK_JOINING; }
|
||||
var result = addNode(type);
|
||||
if (!result) {
|
||||
return;
|
||||
}
|
||||
var nn = result.node;
|
||||
var historyEvent = result.historyEvent;
|
||||
nn.x = point[0];
|
||||
nn.y = point[1];
|
||||
nn.x = Math.ceil((point[0] - 50) / gridSize) * gridSize + 50;
|
||||
nn.y = parseInt(point[1] / gridSize) * gridSize;
|
||||
|
||||
var showLabel = RED.utils.getMessageProperty(RED.settings.get('editor'),"view.view-node-show-label");
|
||||
if (showLabel !== undefined && !/^link (in|out)$/.test(nn._def.type) && !nn._def.defaults.hasOwnProperty("l")) {
|
||||
@ -796,6 +798,7 @@ RED.view = (function() {
|
||||
updateActiveNodes();
|
||||
updateSelection();
|
||||
redraw();
|
||||
if (auto === true) { point[0] = point[0] + ((nn.w < 100) ? 100 : nn.w) + gridSize * 2; }
|
||||
}
|
||||
});
|
||||
|
||||
@ -850,7 +853,6 @@ RED.view = (function() {
|
||||
|
||||
mouse_position = d3.touches(this)[0]||d3.mouse(this);
|
||||
|
||||
|
||||
if (lasso) {
|
||||
var ox = parseInt(lasso.attr("ox"));
|
||||
var oy = parseInt(lasso.attr("oy"));
|
||||
@ -1139,7 +1141,7 @@ RED.view = (function() {
|
||||
updateSelection();
|
||||
lasso.remove();
|
||||
lasso = null;
|
||||
} else if (mouse_mode == RED.state.DEFAULT && mousedown_link == null && !d3.event.ctrlKey&& !d3.event.metaKey ) {
|
||||
} else if (mouse_mode == RED.state.DEFAULT && mousedown_link == null && !d3.event.ctrlKey && !d3.event.metaKey ) {
|
||||
clearSelection();
|
||||
updateSelection();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user