pub struct Button { /* private fields */ }Expand description
A clickable box around one child, which it centers.
While the pointer is over it, hover_style is laid over its style, and
while it is also held down, pressed_style on top of that. Handlers run
on the main thread and receive the button’s Cx. A handler that panics
is logged and never called again.
Implementations§
Source§impl Button
impl Button
Sourcepub fn hover_style(self, style: impl IntoProp<Style>) -> Button
pub fn hover_style(self, style: impl IntoProp<Style>) -> Button
Sets the style laid over the normal one while the pointer is over the button.
Sourcepub fn hovered(self, hovered: Signal<bool>) -> Button
pub fn hovered(self, hovered: Signal<bool>) -> Button
Shares whether the pointer is over the button: the button sets
hovered to true while the pointer is over it or anything inside
it, buttons too, and back to false when it leaves, the window loses
it, or the button goes. Unlike hover_style, which only the deepest
button under the pointer shows, an outer button stays hovered while
the pointer is over one inside it, so it can show controls on hover.
Sourcepub fn pressed_style(self, style: impl IntoProp<Style>) -> Button
pub fn pressed_style(self, style: impl IntoProp<Style>) -> Button
Sets the style laid over the hover style while the button is held down.
Sourcepub fn focus_style(self, style: impl IntoProp<Style>) -> Button
pub fn focus_style(self, style: impl IntoProp<Style>) -> Button
Sets the style laid over the normal one while the button has the keyboard focus, which Tab moves between buttons.
Sourcepub fn on_key(
self,
handler: impl Fn(&Cx, &KeyEvent) -> bool + 'static,
) -> Button
pub fn on_key( self, handler: impl Fn(&Cx, &KeyEvent) -> bool + 'static, ) -> Button
Runs handler for each key pressed while the button has the
keyboard focus. It returns true when it used the key; otherwise the
window’s on_key gets it, and then Tab, Enter and Space do what
they do by default.
Sourcepub fn on_press(self, handler: impl Fn(&Cx) + 'static) -> Button
pub fn on_press(self, handler: impl Fn(&Cx) + 'static) -> Button
Runs handler as soon as the left button goes down over this
button, while it is held: the time to call
Cx::start_move, as a title bar does.
Sourcepub fn on_click(self, handler: impl Fn(&Cx) + 'static) -> Button
pub fn on_click(self, handler: impl Fn(&Cx) + 'static) -> Button
Runs handler when the left button is pressed and released over this
button.
Sourcepub fn on_right_click(self, handler: impl Fn(&Cx) + 'static) -> Button
pub fn on_right_click(self, handler: impl Fn(&Cx) + 'static) -> Button
Runs handler when the right button is pressed and released over this
button.
Sourcepub fn on_middle_click(self, handler: impl Fn(&Cx) + 'static) -> Button
pub fn on_middle_click(self, handler: impl Fn(&Cx) + 'static) -> Button
Runs handler when the middle button is pressed and released over
this button.