I am using Yew, but that shouldn't really matter here
I need to measure the size/location of an HTML element and I can't figure out how to upcast an EventTarget
into an HtmlElement
. I have tried both into
and try_into
:
move |e: web_sys::MouseEvent| {
let elem: web_sys::HtmlElement = e.target().unwrap().try_into().unwrap();
Msg::SetTab(pos, (0, 0))
}
I have tried treating it like an HtmlElement
:
move |e: web_sys::MouseEvent| {
let width = e.target().unwrap().client_width();
Msg::SetTab(pos, (0, 0))
}
How do I go about getting the HtmlElement
, and more importantly, how would I have figured that out from the docs (I have poured over EventTarget
, Node
and HtmlElement
)?