Skip to content

Commit

Permalink
fix(wheel): apply modifiers [alt,shift,ctrl] on wheel event
Browse files Browse the repository at this point in the history
  • Loading branch information
jourdain committed Aug 7, 2024
1 parent cf32041 commit 42f2283
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@
from .web_protocol import ParaViewWebProtocol


def apply_modifiers(event, interactor):
interactor.SetShiftKey(1 if event.get("shiftKey") else 0)
interactor.SetControlKey(1 if event.get("ctrlKey") else 0)
interactor.SetAltKey(1 if event.get("altKey") else 0)
# interactor.SetMetaKey(1 if event.get("metaKey") else 0)


class ParaViewWebPublishImageDelivery(ParaViewWebProtocol):
def __init__(self, decode=True, **kwargs):
super().__init__()
Expand Down Expand Up @@ -600,6 +607,8 @@ def update_zoom_from_wheel(self, event):
# Can't do anything.
return

apply_modifiers(event, interactor)

if "x" in event and "y" in event and interactor.GetRenderWindow():
# Set the mouse position, so that if there are multiple
# renderers, the interactor can figure out which one should
Expand Down
8 changes: 8 additions & 0 deletions trame_vtk/modules/vtk/protocols/mouse_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@
from .web_protocol import vtkWebProtocol


def apply_modifiers(event, interactor):
interactor.SetShiftKey(1 if event.get("shiftKey") else 0)
interactor.SetControlKey(1 if event.get("ctrlKey") else 0)
interactor.SetAltKey(1 if event.get("altKey") else 0)
# interactor.SetMetaKey(1 if event.get("metaKey") else 0)


class vtkWebMouseHandler(vtkWebProtocol):
"""Handle Mouse interaction on any type of view"""

Expand Down Expand Up @@ -77,6 +84,7 @@ def update_zoomFromWheel(self, event):
return

interactor = render_window.GetInteractor()
apply_modifiers(event, interactor)

if "x" in event and "y" in event:
# Set the mouse position, so that if there are multiple
Expand Down

0 comments on commit 42f2283

Please sign in to comment.