Skip to content

Commit

Permalink
Merge pull request #1673 from janezd/force-show-link-dlg
Browse files Browse the repository at this point in the history
[ENH] Canvas: Always show the link dialog if the user holds Shift
  • Loading branch information
lanzagar authored Oct 21, 2016
2 parents 5899ce2 + a6cb8f7 commit 7c9b1ad
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Orange/canvas/document/interactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ def __init__(self, document, *args, **kwargs):
self.sink_item = None
self.from_item = None
self.direction = None
self.force_link_dialog = False

# An `NodeItem` currently under the mouse as a possible
# link drop target.
Expand Down Expand Up @@ -324,6 +325,8 @@ def mousePressEvent(self, event):
self.tr('<h3>Create new link</h3>'
'<p>Drag a link to an existing node or release on '
'an empty spot to create a new node.</p>'
'<p>Hold Shift when releasing the mouse button to '
'edit connections.</p>'
# '<a href="help://orange-canvas/create-new-links">'
# 'More ...</a>'
)
Expand Down Expand Up @@ -392,6 +395,7 @@ def mouseMoveEvent(self, event):

def mouseReleaseEvent(self, event):
if self.tmp_link_item:
self.force_link_dialog = bool(event.modifiers() & Qt.ShiftModifier)
item = self.target_node_item_at(event.scenePos())
node = None
stack = self.document.undoStack()
Expand Down Expand Up @@ -501,7 +505,7 @@ def connect_nodes(self, source_node, sink_node):
# to SchemeLinks later
links_to_add = [(source, sink)]
links_to_remove = []
show_link_dialog = False
show_link_dialog = self.force_link_dialog

# Ambiguous new link request.
if len(possible) >= 2:
Expand Down Expand Up @@ -582,6 +586,8 @@ def connect_nodes(self, source_node, sink_node):
log.error("An error occurred during the creation of a new link.",
exc_info=True)
self.cancel()
finally:
self.force_link_dialog = False

def edit_links(self, source_node, sink_node, initial_links=None):
"""
Expand Down

0 comments on commit 7c9b1ad

Please sign in to comment.