Skip to content

Support right mouse button and preventing default context menu#1830

Merged
axelboc merged 1 commit into
mainfrom
mouse-right
Jun 26, 2025
Merged

Support right mouse button and preventing default context menu#1830
axelboc merged 1 commit into
mainfrom
mouse-right

Conversation

@axelboc

@axelboc axelboc commented Jun 25, 2025

Copy link
Copy Markdown
Contributor

Fix #1813

  • Interactions like Pan, SelectToZoom, etc. can now be configured with the right mouse button.
  • A new component called PreventDefaultContextMenu prevents the browser from showing its native context menu on right-click. Prop when controls this behaviour:
    • with 'as-needed' (the default), the context menu is prevented only when an interaction based on the right mouse button is registered and enabled;
    • with 'always', the context menu is always prevented regardless of registered interactions;
    • with 'never', the context menu is never prevented regardless of registered interactions.
  • In order for PreventDefaultContextMenu to be able to access registered interactions, I expose a getInteractions function through the existing InteractionsContext. It returns all registered interactions by default, but it can also filter them when given a specific mouse button/modifier key.
  • I add PreventDefaultContextMenu to DefaultInteractions so it works out of the box in all high-level visualization components (LineVis, etc.).
  • In the Storybook, I document InteractionsContext, getInteractions and PreventDefaultContextMenu, and I add a Pan story with the right mouse button.
Screencast.from.2025-06-25.14-49-38.webm

@axelboc axelboc force-pushed the mouse-right branch 3 times, most recently from 8f878c1 to 7b84def Compare June 25, 2025 13:49
@axelboc axelboc requested a review from loichuder June 25, 2025 13:50

@loichuder loichuder left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well thought-out 👏

Comment thread packages/lib/src/interactions/InteractionsProvider.tsx Outdated
@axelboc axelboc merged commit bc2dabc into main Jun 26, 2025
9 checks passed
@axelboc axelboc deleted the mouse-right branch June 26, 2025 06:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

@h5web/lib limitations on mouse buttons and modifier keys

2 participants