Replies: 1 comment 2 replies
-
I think Dioxus desktop should provide a custom handler or listener for this so it's easier to implement a real right-click menu. Anyways, you can manually override the code that interrupts the context menu with the From there, you can inject your own scripts with the For reference, this is the code that runs when if cfg.disable_context_menu {
// in release mode, we don't want to show the dev tool or reload menus
webview = webview.with_initialization_script(
r#"
if (document.addEventListener) {
document.addEventListener('contextmenu', function(e) {
alert("You've tried to open context menu");
e.preventDefault();
}, false);
} else {
document.attachEvent('oncontextmenu', function() {
alert("You've tried to open context menu");
window.event.returnValue = false;
});
}
"#,
)
} else {
// in debug, we are okay with the reload menu showing and dev tool
webview = webview.with_dev_tool(true);
} |
Beta Was this translation helpful? Give feedback.
-
I wondered if it is possible to prevent the default action when clicking the right mouse button. When I compile in debug mode, I get the default context menu (with "Inspect element" and other stuff), and in release mode I get a popup saying that I tried to open the context menu. I want to execute a custom action on right-clicking and already found out that I can do this, for example, by using the oncontextmenu event. However, the aforementioned default actions always get in the way. I experimented a bit with prevent_default and cancel_bubble on several events, but so far I have not been successful.
Beta Was this translation helpful? Give feedback.
All reactions