-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Access to Events in handlers (virtual DOM) #44
Comments
I’m on mobile for the weekend so forgive any typos So the !myevent closure would have one Event parameter and then you could just convert it into any other type of event that you wanted? That makes a lot of sense to me and I a pretty quick win. We’d just need to update https://github.com/chinedufn/percy/blob/master/crates/virtual-node/src/lib.rs#L386 to be FnMut(Event) Interested in taking a stab at this? I’d be happy to answer any questions! Otherwise I should be back to my machine later this weekend and I can take a look! |
I'll give it a look, but I'm working on some other things right now too. If you find the time first, go on ahead! |
@agrif thanks for raising the issue! You can now you any Commit -> ab4e8c3 example: html! { <div !onclick=|ev: web_sys::MouseEvent| {}></div> } |
Unless I'm mistaken, there isn't currently any way to access the event itself inside event handlers.
It looks like some support for this was added recently for
oninput
, and I think that route is maybe a bit labor intensive but worth pursuing.However, in the meantime, would it be possible to let generic handlers access their event? Either as a Event struct, or an even more generic JsValue. This maybe isn't a very pleasant API, but it would be a quick win, and let us actually inspect the events for things like keycodes that aren't available any other way.
The text was updated successfully, but these errors were encountered: