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§
Sourcefn style(self, style: ButtonStyle) -> Self
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.
Sourcefn size(self, size: ButtonSize) -> Self
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.
Sourcefn tooltip(
self,
tooltip: impl Fn(&mut Window, &mut App) -> AnyView + 'static,
) -> Self
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.
fn tab_index(self, tab_index: impl Into<isize>) -> Self
fn layer(self, elevation: ElevationIndex) -> Self
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".