Rust, stdweb, add_event_listener, disable right click

  1. To disable right click, as in https://www.computerhope.com/javascript/disable-right-click.htm it appears we need to “return false” in the event handler.

  2. I’m not doing this globally, just for a small canvas/WebGL window.

  3. However, stdweb’s add_event_listener wants functions of type “event -> ()”

  4. Is there anyway to make this work within existing stdweb, or does this involve lots of js! macros ?

https://docs.rs/stdweb/0.4.17/stdweb/web/event/trait.IEvent.html#method.prevent_default

Unfortunately, calling evt.prevent_default() is not enough.
EDIT:

More specifically, I’ve already done evt.prevent_default() on the MouseDownEvent, MouseUpEvent, and MouseMoveEvent.

This by itself is not sufficient.

EDIT2:

I’m using Chrome on Linux.

Appears simplest way to solve is this

<body oncontextmenu="return false;">
...
</body>