Skip to content

Commit

Permalink
Propagate whether mouse release handler handles event
Browse files Browse the repository at this point in the history
Propagate further the result of the mouse release handler, and made sure that if a handler had successfully handled the event to set the correct flag on the event to stop Qt re-raising it to one element further up in the display heirarchy.
  • Loading branch information
Tiomat85 committed Jul 29, 2024
1 parent c79a7c4 commit 0b25b7f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion nion/ui/PyQtProxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -2112,7 +2112,9 @@ def mouseReleaseEvent(self, event: QtGui.QMouseEvent) -> None:
if self.object and event.button() == QtCore.Qt.LeftButton:
display_scaling = GetDisplayScaling()
try:
self.object.mouseReleased(event.position().x() // display_scaling, event.position().y() // display_scaling, event.modifiers().value)
result = self.object.mouseReleased(event.position().x() // display_scaling, event.position().y() // display_scaling, event.modifiers().value)
if result:
event.accept()
except Exception as e:
import traceback
traceback.print_exc()
Expand Down
4 changes: 2 additions & 2 deletions nion/ui/QtUserInterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -1659,10 +1659,10 @@ def mousePressed(self, x: int, y: int, raw_modifiers: int) -> None:
if callable(self.on_mouse_pressed):
self.on_mouse_pressed(x, y, QtKeyboardModifiers(raw_modifiers))

def mouseReleased(self, x: int, y: int, raw_modifiers: int) -> None:
def mouseReleased(self, x: int, y: int, raw_modifiers: int) -> bool:
self._register_ui_activity()
if callable(self.on_mouse_released):
self.on_mouse_released(x, y, QtKeyboardModifiers(raw_modifiers))
return self.on_mouse_released(x, y, QtKeyboardModifiers(raw_modifiers))

def mousePositionChanged(self, x: int, y: int, raw_modifiers: int) -> None:
if callable(self.on_mouse_position_changed):
Expand Down

0 comments on commit 0b25b7f

Please sign in to comment.