Function dioxus_html::events::onclick
source · pub fn onclick<'a, E: EventReturn<T>, T>(
_cx: &'a ScopeState,
_f: impl FnMut(Event<MouseData>) -> E + 'a
) -> Attribute<'a>
Expand description
Execute a callback when a button is clicked.
Description
An element receives a click event when a pointing device button (such as a mouse’s primary mouse button) is both pressed and released while the pointer is located inside the element.
- Bubbles: Yes
- Cancelable: Yes
- Interface(InteData):
MouseEvent
If the button is pressed on one element and the pointer is moved outside the element before the button
is released, the event is fired on the most specific ancestor element that contained both elements.
click
fires after both the mousedown
and mouseup
events have fired, in that order.
Example
ⓘ
rsx!( button { "click me", onclick: move |_| tracing::info!("Clicked!`") } )