Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a signal_NodeRightClicked that is emitted when the user right click on a node #28

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ signal_NodeDeleted([nodeNames])
signal_NodeEdited(oldName, newName)
signal_NodeSelected([nodeNames])
signal_NodeMoved(nodeName, nodePos)
signal_NodeRightClicked(nodeName)
signal_NodeDoubleClicked(nodeName)
```
Attributes
Expand Down
5 changes: 5 additions & 0 deletions nodz_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ def on_nodeSelected(nodesName):
def on_nodeMoved(nodeName, nodePos):
print 'node {0} moved to {1}'.format(nodeName, nodePos)

@QtCore.Slot(str)
def on_nodeRightClick(nodeName):
print 'right click on node : {0}'.format(nodeName)

@QtCore.Slot(str)
def on_nodeDoubleClick(nodeName):
print 'double click on node : {0}'.format(nodeName)
Expand Down Expand Up @@ -91,6 +95,7 @@ def on_keyPressed(key):
nodz.signal_NodeEdited.connect(on_nodeEdited)
nodz.signal_NodeSelected.connect(on_nodeSelected)
nodz.signal_NodeMoved.connect(on_nodeMoved)
nodz.signal_NodeRightClicked.connect(on_nodeRightClick)
nodz.signal_NodeDoubleClicked.connect(on_nodeDoubleClick)

nodz.signal_AttrCreated.connect(on_attrCreated)
Expand Down
6 changes: 5 additions & 1 deletion nodz_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class Nodz(QtWidgets.QGraphicsView):
signal_NodeEdited = QtCore.Signal(object, object)
signal_NodeSelected = QtCore.Signal(object)
signal_NodeMoved = QtCore.Signal(str, object)
signal_NodeRightClicked = QtCore.Signal(str)
signal_NodeDoubleClicked = QtCore.Signal(str)

signal_AttrCreated = QtCore.Signal(object, object)
Expand Down Expand Up @@ -1475,7 +1476,10 @@ def mouseReleaseEvent(self, event):

"""
# Emit node moved signal.
self.scene().signal_NodeMoved.emit(self.name, self.pos())
if(event.button() == QtCore.Qt.MouseButton.LeftButton):
self.scene().signal_NodeMoved.emit(self.name, self.pos())
if(event.button() == QtCore.Qt.MouseButton.RightButton):
self.scene().parent().signal_NodeRightClicked.emit(self.name)
super(NodeItem, self).mouseReleaseEvent(event)

def hoverLeaveEvent(self, event):
Expand Down