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

Clear mouse state when typeSearch cancelled

Fixes #1517
This commit is contained in:
Nick O'Leary 2018-01-13 23:46:16 +00:00
parent cb4120ec4b
commit 298068b2b9
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
2 changed files with 16 additions and 3 deletions

View File

@ -12,6 +12,7 @@ RED.typeSearch = (function() {
var activeFilter = ""; var activeFilter = "";
var addCallback; var addCallback;
var cancelCallback;
var typesUsed = {}; var typesUsed = {};
@ -155,11 +156,19 @@ RED.typeSearch = (function() {
t = t.parent(); t = t.parent();
} }
hide(true); hide(true);
if (cancelCallback) {
cancelCallback();
}
} }
} }
function show(opts) { function show(opts) {
if (!visible) { if (!visible) {
RED.keyboard.add("*","escape",function(){hide()}); RED.keyboard.add("*","escape",function(){
hide();
if (cancelCallback) {
cancelCallback();
}
});
if (dialog === null) { if (dialog === null) {
createDialog(); createDialog();
} }
@ -175,6 +184,7 @@ RED.typeSearch = (function() {
} }
refreshTypeList(); refreshTypeList();
addCallback = opts.add; addCallback = opts.add;
closeCallback = opts.close;
RED.events.emit("type-search:open"); RED.events.emit("type-search:open");
//shade.show(); //shade.show();
dialog.css({left:opts.x+"px",top:opts.y+"px"}).show(); dialog.css({left:opts.x+"px",top:opts.y+"px"}).show();

View File

@ -546,6 +546,9 @@ RED.view = (function() {
RED.typeSearch.show({ RED.typeSearch.show({
x:d3.event.clientX-mainPos.left-node_width/2, x:d3.event.clientX-mainPos.left-node_width/2,
y:d3.event.clientY-mainPos.top-node_height/2, y:d3.event.clientY-mainPos.top-node_height/2,
cancel: function() {
resetMouseVars();
},
add: function(type) { add: function(type) {
var result = addNode(type); var result = addNode(type);
if (!result) { if (!result) {
@ -683,7 +686,7 @@ RED.view = (function() {
var mousePos; var mousePos;
if (mouse_mode == RED.state.JOINING || mouse_mode === RED.state.QUICK_JOINING) { if (mouse_mode == RED.state.JOINING || mouse_mode === RED.state.QUICK_JOINING) {
// update drag line // update drag line
if (drag_lines.length === 0) { if (drag_lines.length === 0 && mousedown_port_type !== null) {
if (d3.event.shiftKey) { if (d3.event.shiftKey) {
// Get all the wires we need to detach. // Get all the wires we need to detach.
var links = []; var links = [];
@ -1348,7 +1351,7 @@ RED.view = (function() {
mouseup_node = null; mouseup_node = null;
mousedown_link = null; mousedown_link = null;
mouse_mode = 0; mouse_mode = 0;
mousedown_port_type = PORT_TYPE_OUTPUT; mousedown_port_type = null;
activeSpliceLink = null; activeSpliceLink = null;
spliceActive = false; spliceActive = false;
d3.select(".link_splice").classed("link_splice",false); d3.select(".link_splice").classed("link_splice",false);