From 298068b2b97e6682c3c22d7e5ff7be4bfc13ef0e Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Sat, 13 Jan 2018 23:46:16 +0000 Subject: [PATCH] Clear mouse state when typeSearch cancelled Fixes #1517 --- editor/js/ui/typeSearch.js | 12 +++++++++++- editor/js/ui/view.js | 7 +++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/editor/js/ui/typeSearch.js b/editor/js/ui/typeSearch.js index 240aeca3c..e3cb7f1ee 100644 --- a/editor/js/ui/typeSearch.js +++ b/editor/js/ui/typeSearch.js @@ -12,6 +12,7 @@ RED.typeSearch = (function() { var activeFilter = ""; var addCallback; + var cancelCallback; var typesUsed = {}; @@ -155,11 +156,19 @@ RED.typeSearch = (function() { t = t.parent(); } hide(true); + if (cancelCallback) { + cancelCallback(); + } } } function show(opts) { if (!visible) { - RED.keyboard.add("*","escape",function(){hide()}); + RED.keyboard.add("*","escape",function(){ + hide(); + if (cancelCallback) { + cancelCallback(); + } + }); if (dialog === null) { createDialog(); } @@ -175,6 +184,7 @@ RED.typeSearch = (function() { } refreshTypeList(); addCallback = opts.add; + closeCallback = opts.close; RED.events.emit("type-search:open"); //shade.show(); dialog.css({left:opts.x+"px",top:opts.y+"px"}).show(); diff --git a/editor/js/ui/view.js b/editor/js/ui/view.js index 453066f58..06ee3d505 100644 --- a/editor/js/ui/view.js +++ b/editor/js/ui/view.js @@ -546,6 +546,9 @@ RED.view = (function() { RED.typeSearch.show({ x:d3.event.clientX-mainPos.left-node_width/2, y:d3.event.clientY-mainPos.top-node_height/2, + cancel: function() { + resetMouseVars(); + }, add: function(type) { var result = addNode(type); if (!result) { @@ -683,7 +686,7 @@ RED.view = (function() { var mousePos; if (mouse_mode == RED.state.JOINING || mouse_mode === RED.state.QUICK_JOINING) { // update drag line - if (drag_lines.length === 0) { + if (drag_lines.length === 0 && mousedown_port_type !== null) { if (d3.event.shiftKey) { // Get all the wires we need to detach. var links = []; @@ -1348,7 +1351,7 @@ RED.view = (function() { mouseup_node = null; mousedown_link = null; mouse_mode = 0; - mousedown_port_type = PORT_TYPE_OUTPUT; + mousedown_port_type = null; activeSpliceLink = null; spliceActive = false; d3.select(".link_splice").classed("link_splice",false);