Skip to main content

ButtonCommon

Trait ButtonCommon 

Source
pub trait ButtonCommon: Clickable + Disableable {
    // Required methods
    fn id(&self) -> &ElementId;
    fn style(self, style: ButtonStyle) -> Self;
    fn size(self, size: ButtonSize) -> Self;
    fn tooltip(
        self,
        tooltip: impl Fn(&mut Window, &mut App) -> AnyView + 'static,
    ) -> Self;
    fn tab_index(self, tab_index: impl Into<isize>) -> Self;
    fn layer(self, elevation: ElevationIndex) -> Self;
    fn track_focus(self, focus_handle: &FocusHandle) -> Self;
}
Expand description

A common set of traits all buttons must implement.

Required Methods§

Source

fn id(&self) -> &ElementId

A unique element ID to identify the button.

Source

fn style(self, style: ButtonStyle) -> Self

The visual style of the button.

Most commonly will be ButtonStyle::Subtle, or ButtonStyle::Filled for an emphasized button.

Source

fn size(self, size: ButtonSize) -> Self

The size of the button.

Most buttons will use the default size.

ButtonSize can also be used to help build non-button elements that are consistently sized with buttons.

Source

fn tooltip( self, tooltip: impl Fn(&mut Window, &mut App) -> AnyView + 'static, ) -> Self

The tooltip that shows when a user hovers over the button.

Nearly all interactable elements should have a tooltip. Some example exceptions might a scroll bar, or a slider.

Source

fn tab_index(self, tab_index: impl Into<isize>) -> Self

Source

fn layer(self, elevation: ElevationIndex) -> Self

Source

fn track_focus(self, focus_handle: &FocusHandle) -> Self

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§