mirror of
https://github.com/FliegendeWurst/cursive.git
synced 2024-11-10 03:10:41 +00:00
Button: add a way to get its label
This commit is contained in:
parent
14f2bf636c
commit
0666a8b585
@ -84,6 +84,21 @@ impl Button {
|
||||
self.enabled
|
||||
}
|
||||
|
||||
/// Returns the label for this button.
|
||||
///
|
||||
/// Includes brackets.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// # use cursive::views::Button;
|
||||
/// let button = Button::new("Quit", |s| s.quit());
|
||||
/// assert_eq!(button.label(), "<Quit>");
|
||||
/// ```
|
||||
pub fn label(&self) -> &str {
|
||||
&self.label
|
||||
}
|
||||
|
||||
fn req_size(&self) -> Vec2 {
|
||||
Vec2::new(self.label.width(), 1)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user