diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 9649c2e9d..083e82d3e 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -35,7 +35,7 @@ zjosua Arthur Milchior Yngve Hoiseth Ijgnd -Yoonchae Lee +Yoonchae Lee Evandro Coan Alan Du Yuchen Lei diff --git a/qt/aqt/sidebar.py b/qt/aqt/sidebar.py index 60a0ebc69..41856e3c7 100644 --- a/qt/aqt/sidebar.py +++ b/qt/aqt/sidebar.py @@ -442,11 +442,13 @@ class SidebarTreeView(QTreeView): def mouseReleaseEvent(self, event: QMouseEvent) -> None: super().mouseReleaseEvent(event) if event.button() == Qt.LeftButton: - self._on_click_current() + idx = self.indexAt(event.pos()) + self._on_click_index(idx) def keyPressEvent(self, event: QKeyEvent) -> None: if event.key() in (Qt.Key_Return, Qt.Key_Enter): - self._on_click_current() + idx = self.currentIndex() + self._on_click_index(idx) else: super().keyPressEvent(event) @@ -516,8 +518,7 @@ class SidebarTreeView(QTreeView): self.browser.editor.saveNow(on_save) return True - def _on_click_current(self) -> None: - idx = self.currentIndex() + def _on_click_index(self, idx: QModelIndex) -> None: if item := self.model().item_for_index(idx): if item.on_click: item.on_click()