Adds doc comment for disabled button
Makes disabled button behavior consistent in web
This commit is contained in:
parent
0e70b11e00
commit
dbc1181011
3 changed files with 31 additions and 8 deletions
|
|
@ -29,6 +29,13 @@ use std::hash::Hash;
|
|||
/// let button = Button::new(&mut state, Text::new("Press me!"))
|
||||
/// .on_press(Message::ButtonPressed);
|
||||
/// ```
|
||||
///
|
||||
/// Buttons can be disabled by not having an on_press.
|
||||
///
|
||||
/// ```
|
||||
/// let mut state = button::State::new();
|
||||
/// let disabled_button = Button::new(&mut state, Text::new("I'm disabled!"));
|
||||
/// ```
|
||||
#[allow(missing_debug_implementations)]
|
||||
pub struct Button<'a, Message, Renderer: self::Renderer> {
|
||||
state: &'a mut State,
|
||||
|
|
@ -97,6 +104,7 @@ where
|
|||
}
|
||||
|
||||
/// Sets the message that will be produced when the [`Button`] is pressed.
|
||||
/// If on_press isn't set, button will be disabled.
|
||||
pub fn on_press(mut self, msg: Message) -> Self {
|
||||
self.on_press = Some(msg);
|
||||
self
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue