- in Tcl Shell Dock widget make sure that the context menu is not shown on the title bar and middle clicking on the title bar will close the widget

This commit is contained in:
Marius Stanciu
2020-12-09 23:28:08 +02:00
committed by Marius
parent 1f65c9c05f
commit 900af55be0
2 changed files with 10 additions and 0 deletions

View File

@@ -4292,6 +4292,15 @@ class FCDock(QtWidgets.QDockWidget):
super(FCDock, self).__init__(*args)
self.close_callback = kwargs["close_callback"] if "close_callback" in kwargs else None
self.setContextMenuPolicy(Qt.PreventContextMenu)
def mousePressEvent(self, event: QtGui.QMouseEvent) -> None:
if event.button() == Qt.MiddleButton:
try:
self.close_callback()
except Exception:
pass
def closeEvent(self, event: QtGui.QCloseEvent) -> None:
self.close_callback()
super().closeEvent(event)