[−][src]Struct cursive::views::Dialog
Popup-like view with a main content, and optional buttons under it.
Examples
let dialog = Dialog::around(TextView::new("Hello!")) .button("Ok", |s| s.quit());
Methods
impl Dialog
[src]
pub fn new() -> Self
[src]
Creates a new Dialog
with empty content.
You should probably call content()
next.
pub fn around<V: View + 'static>(view: V) -> Self
[src]
Creates a new Dialog
with the given content.
pub fn content<V: View + 'static>(self, view: V) -> Self
[src]
Sets the content for this dialog.
Chainable variant.
pub fn get_content(&self) -> &dyn View
[src]
Gets the content of this dialog.
use cursive::views::{Dialog, TextView}; let dialog = Dialog::around(TextView::new("Hello!")); let text_view: &TextView = dialog .get_content() .as_any() .downcast_ref::<TextView>() .unwrap(); assert_eq!(text_view.get_content().source(), "Hello!");
pub fn get_content_mut(&mut self) -> &mut dyn View
[src]
Gets mutable access to the content.
pub fn set_content<V: View + 'static>(&mut self, view: V)
[src]
Sets the content for this dialog.
Previous content will be dropped.
pub fn text<S: Into<String>>(text: S) -> Self
[src]
Convenient method to create a dialog with a simple text content.
pub fn info<S: Into<String>>(text: S) -> Self
[src]
Convenient method to create an infobox.
It will contain the given text and a Ok
dismiss button.
pub fn button<F, S: Into<String>>(self, label: S, cb: F) -> Self where
F: 'static + Fn(&mut Cursive),
[src]
F: 'static + Fn(&mut Cursive),
Adds a button to the dialog with the given label and callback.
Consumes and returns self for easy chaining.
pub fn add_button<F, S: Into<String>>(&mut self, label: S, cb: F) where
F: 'static + Fn(&mut Cursive),
[src]
F: 'static + Fn(&mut Cursive),
Adds a button to the dialog with the given label and callback.
pub fn buttons_len(&self) -> usize
[src]
Returns the number of buttons on this dialog.
pub fn clear_buttons(&mut self)
[src]
Removes any button from self
.
pub fn remove_button(&mut self, i: usize)
[src]
pub fn h_align(self, h: HAlign) -> Self
[src]
Sets the horizontal alignment for the buttons, if any.
Only works if the buttons are as a row at the bottom of the dialog.
pub fn dismiss_button<S: Into<String>>(self, label: S) -> Self
[src]
Shortcut method to add a button that will dismiss the dialog.
pub fn title<S: Into<String>>(self, label: S) -> Self
[src]
Sets the title of the dialog.
If not empty, it will be visible at the top.
pub fn set_title<S: Into<String>>(&mut self, label: S)
[src]
Sets the title of the dialog.
pub fn title_position(self, align: HAlign) -> Self
[src]
Sets the horizontal position of the title in the dialog.
The default position is HAlign::Center
pub fn set_title_position(&mut self, align: HAlign)
[src]
Sets the horizontal position of the title in the dialog.
The default position is HAlign::Center
pub fn padding<T: Into<Margins>>(self, padding: T) -> Self
[src]
Sets the padding in the dialog (around content and buttons).
pub fn padding_top(self, padding: usize) -> Self
[src]
Sets the top padding in the dialog (under the title).
pub fn padding_bottom(self, padding: usize) -> Self
[src]
Sets the bottom padding in the dialog (under buttons).
pub fn padding_left(self, padding: usize) -> Self
[src]
Sets the left padding in the dialog.
pub fn padding_right(self, padding: usize) -> Self
[src]
Sets the right padding in the dialog.
pub fn buttons_mut(&mut self) -> impl Iterator<Item = &mut Button>
[src]
Returns an iterator on this buttons for this dialog.
pub fn focus(&self) -> DialogFocus
[src]
Returns currently focused element
Trait Implementations
impl View for Dialog
[src]
fn draw(&self, printer: &Printer)
[src]
fn required_size(&mut self, req: Vec2) -> Vec2
[src]
fn layout(&mut self, size: Vec2)
[src]
fn on_event(&mut self, event: Event) -> EventResult
[src]
fn take_focus(&mut self, source: Direction) -> bool
[src]
fn call_on_any<'a>(&mut self, selector: &Selector, callback: AnyCb<'a>)
[src]
fn focus_view(&mut self, selector: &Selector) -> Result<(), ()>
[src]
fn important_area(&self, _: Vec2) -> Rect
[src]
fn needs_relayout(&self) -> bool
[src]
impl Default for Dialog
[src]
Auto Trait Implementations
impl Unpin for Dialog
impl !Sync for Dialog
impl !Send for Dialog
impl !UnwindSafe for Dialog
impl !RefUnwindSafe for Dialog
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,