Merge pull request #443 from vkbo/middle_button

Middle Mouse Button
This commit is contained in:
Veronica K. Berglyd Olsen
2020-09-08 23:20:15 +02:00
committed by GitHub
+16 -1
View File
@@ -662,14 +662,29 @@ class GuiProjectTree(QTreeWidget):
def mousePressEvent(self, theEvent): def mousePressEvent(self, theEvent):
"""Overload mousePressEvent to clear selection if clicking the """Overload mousePressEvent to clear selection if clicking the
mouse in a blank area of the tree view. mouse in a blank area of the tree view, and to load a document
for viewing if the suer middle clicked.
""" """
QTreeWidget.mousePressEvent(self, theEvent) QTreeWidget.mousePressEvent(self, theEvent)
if theEvent.button() == Qt.LeftButton:
selItem = self.indexAt(theEvent.pos()) selItem = self.indexAt(theEvent.pos())
if not selItem.isValid(): if not selItem.isValid():
self.clearSelection() self.clearSelection()
elif theEvent.button() == Qt.MiddleButton:
selItem = self.itemAt(theEvent.pos())
if not isinstance(selItem, QTreeWidgetItem):
return
tHandle = selItem.data(self.C_NAME, Qt.UserRole)
tItem = self.theProject.projTree[tHandle]
if tItem is None:
return
if tItem.itemType == nwItemType.FILE:
self.theParent.viewDocument(tHandle)
return return
def dropEvent(self, theEvent): def dropEvent(self, theEvent):