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

Middle Mouse Button #443

Merged
merged 1 commit into from
Sep 8, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 19 additions & 4 deletions nw/gui/projtree.py
Original file line number Diff line number Diff line change
Expand Up @@ -662,13 +662,28 @@ def _rightClickMenu(self, clickPos):

def mousePressEvent(self, theEvent):
"""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)

selItem = self.indexAt(theEvent.pos())
if not selItem.isValid():
self.clearSelection()
if theEvent.button() == Qt.LeftButton:
selItem = self.indexAt(theEvent.pos())
if not selItem.isValid():
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

Expand Down