Rust, stdweb, add_event_listener, disable right click

  1. To disable right click, as in 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 ?

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

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

This by itself is not sufficient.


I’m using Chrome on Linux.

Appears simplest way to solve is this

<body oncontextmenu="return false;">