In JavaScript, the addEventListener() method is used like this:
object.addEventListener("click", myScript);
In Scala.js: I have a canvas, and I want to listen to clicks only on the canvas, not the entire document. In the Scala.js.dom library, addEventListener is defined as:
def addEventListener(`type`: String, listener: js.Function1[Event, _], useCapture: Boolean = ???): Unit = ???
I'm not sure what "useCapture" refers to. But I tried:
dom.document.getElementById("canvas").addEventListener("click", {
(e:dom.MouseEvent) => { /*do something*/ }
}, false)
And the error message I got:
found : org.scalajs.dom.MouseEvent => Unit
required: scala.scalajs.js.Function1[org.scalajs.dom.Event, _]
Can someone explain what "useCapture" refers to, and how to correctly use addEventListener in Scala.js?