-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Callback for context menu #1122
Comments
I'm not sure we can provide an API that is simpler than what the browser and R3F already provide, namely the <Html>
<rect
// ...
onContextMenu={(evt) => {
/* Tell the browser not to show the default context menu.
* (You may want to consider preventing the default action only when a modifier key is pressed,
* or the contrary: allowing the default action when a modifier key is pressed, like on YouTube.) */
evt.preventDefault();
/* Then set the position of the new context menu tooltip in a local state.
* Below is an example with @visx/tooltip, but you could use another tooltip/context menu implementation. */
showTooltip({ tooltipLeft: evt.offsetX, tooltipTop: evt.offsetY });
}}
</Html>
/> You can also pass the <HeatmapMesh
// ...
onContextMenu={...}
/> For global actions on the canvas, you can use const { domElement } = useThree((state) => state.gl);
useEventListener(domElement, 'contextmenu', handleContextMenu); All that being said, when it comes to UX, you should consider using the floating toolbar instead of context menus, as it would make your actions more discoverable: https://h5web-docs.panosc.eu/?path=/story/toolbar-floatingtoolbar--default. The floating toolbar can even be used for contextual actions: you can show/enable floating controls based on what the user is currently doing - e.g. show a "delete" button when the user selects a ROI. |
I am mostly talking about an high level API aggregations context menu options from different level of depth. Example
If the mouse is over this 2 items at the same time, all this options will be exposed. That's what is provided by If an I will not talk about user experience. The most import thing for me is to have flexibility, and to be able to provide features at low cost. |
Hi,
I think it would be good to reserve the right mouse click to context menu.
There is a need of global action on the plot (for example managing an application specific pan/zoom history), or specific to plot objects, like ROIs.
PyQtGraph
examples. But this could be easier, i can't tell.It's not urgent feature (because we will always find other solutions), but such API could be really helpful for developers and users.
The text was updated successfully, but these errors were encountered: