vugu / vugu

Vugu: A modern UI library for Go+WebAssembly (experimental)
https://www.vugu.org
MIT License
4.8k stars 175 forks source link

How to get event on @click? #165

Closed Nv7-GitHub closed 3 years ago

Nv7-GitHub commented 3 years ago

Question is there a way of getting the event js.Value on @click and other functions?

Suggested Changes If not, could that be a feature?

Additional context I want to get the target of the click function.

bradleypeabody commented 3 years ago

I think you're looking for JSEvent() on DOMEvent. JSEventTarget() and JSEventCurrentTarget() are also available and probably will give you want you want.

Nv7-GitHub commented 3 years ago

How would you get this DOMEvent from inside an onclick function?

bradleypeabody commented 3 years ago

The relevant documentation is here: https://www.vugu.org/doc/dom-events

The special variable event (of type vugu.DOMEvent) corresponds to the event data sent to us by the browser. It also provides some useful functionality such as a PreventDefault() method which corresponds to preventDefault

Nv7-GitHub commented 3 years ago

How did I not notice that? Thanks!