Skip to content

Commit

Permalink
Fix signature zooming in linux
Browse files Browse the repository at this point in the history
  • Loading branch information
srwi committed Feb 20, 2024
1 parent 37b6434 commit f465f7f
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/mocksign/mocksign.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,11 @@ def _on_graph_mouse_wheel(self, values: Dict[str, Any]) -> None:
if not values["-PLACE-"] or not self._selected_signature_image:
return

is_mouse_wheel_up = self._graph.user_bind_event.delta > 0
if self._graph.user_bind_event.delta != 0:
is_mouse_wheel_up = self._graph.user_bind_event.delta > 0
else:
# Linux does not provide the delta value, so we need to infer it from the event number
is_mouse_wheel_up = self._graph.user_bind_event.num == 4
self._signature_zoom_level *= 1.1 if is_mouse_wheel_up else 0.9

cursor_xy = values["-GRAPH-"]
Expand Down Expand Up @@ -441,7 +445,9 @@ def start(self) -> None:

self._graph = self._window["-GRAPH-"]
self._graph.bind("<Leave>", "+LEAVE")
self._graph.bind("<MouseWheel>", "+WHEEL")
self._graph.bind("<MouseWheel>", "+WHEEL") # Windows event
self._graph.bind("<Button-4>", "+WHEEL") # Linux event
self._graph.bind("<Button-5>", "+WHEEL") # Linux event

self._event_handlers[sg.WIN_CLOSED] = self._on_windown_closed
self._event_handlers["-CONFIGURE-"] = self._on_window_resized
Expand Down

0 comments on commit f465f7f

Please sign in to comment.