Function dioxus::events::onclick

source ·
pub fn onclick<E, T>(
    _f: impl FnMut(Event<MouseData>) -> E + 'static
) -> Attribute
where E: EventReturn<T>,
Available on crate feature html only.
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!`") } )

§Reference