Struct StdButton

Source
pub struct StdButton { /* private fields */ }
Expand description

Standard button that returns some result based on whether a key is pressed

§Examples

use oxide::core::{HorizontalAlign, VerticalAlign, ButtonResult, Widget};
use oxide::{Dialog, StdButton};

let mut dlg = Dialog::new(60, 10);

let mut b1 = StdButton::new("Foo", 'f', ButtonResult::Ok);
let mut b2 = StdButton::new("Bar" ,'b', ButtonResult::Cancel);

b1.pack(&dlg, HorizontalAlign::Left, VerticalAlign::Middle, (1,1));
b2.pack(&dlg, HorizontalAlign::Middle, VerticalAlign::Middle, (1,1));

dlg.add_button(b1);
dlg.add_button(b2);

Implementations§

Source§

impl StdButton

Source

pub fn new(text: &str, accel: char, result: ButtonResult) -> StdButton

Constructs a new StdButton, asking for the text to be displayed by the button, the key to map to, and the result returned when the key is detected

§Examples
use oxide::core::ButtonResult;
use oxide::StdButton;

let mut b1 = StdButton::new("Foo", 'f', ButtonResult::Ok);

Trait Implementations§

Source§

impl Button for StdButton

Source§

fn accel(&self) -> char

Return the char that is acting as the key in the Button
Source§

fn result(&self) -> ButtonResult

Return the ButtonResult which would be returned if the key is detected
Source§

fn pressed(&mut self)

If a button is to do some special action upon being pressed, then this function will do so. StdButton for example does nothing when pressed, while CheckButton changes it’s ballot
Source§

fn state(&self) -> bool

If a button has a state involved, e.g. needs to keep track of a certain event, this function will return the state of the button.
Source§

impl Widget for StdButton

Source§

fn draw(&mut self, parent: &mut dyn CellAccessor)

Draws the widget to the valid CellAccessor passed
Source§

fn pack( &mut self, parent: &dyn HasSize, halign: HorizontalAlign, valign: VerticalAlign, margin: (usize, usize), )

Aligns the widget with the parent as reference
Source§

fn draw_box(&mut self)

Expose the painter trait draw_box for all widgets, which outlines the space enclosed within the widget
Source§

fn resize(&mut self, new_size: Size)

Resize the given widget to new dimensions given by Size
Source§

fn frame(&self) -> &Frame

Return a reference the renderer, Base in general cases
Source§

fn frame_mut(&mut self) -> &mut Frame

Return a mutable reference to the renderer, Base in general cases

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.