Struct cursive::prelude::Dialog [] [src]

pub struct Dialog {
    // some fields omitted
}

Popup-like view with a main content, and optional buttons under it.

Examples

let dialog = Dialog::new(TextView::new("Hello!"))
                    .button("Ok", |s| s.quit());

Methods

impl Dialog
[src]

fn empty() -> Self

Creates a new Dialog with empty content.

You should probably call content() next.

fn new<V: View + 'static>(view: V) -> Self

Creates a new Dialog with the given content.

fn content<V: View + 'static>(self, view: V) -> Self

Sets the content for this dialog.

Chainable variant.

fn set_content<V: View + 'static>(&mut self, view: V)

Sets the content for this dialog.

Previous content will be dropped.

fn text<S: Into<String>>(text: S) -> Self

Convenient method to create a dialog with a simple text content.

fn info<S: Into<String>>(text: S) -> Self

Convenient method to create an infobox.

It will contain the given text and a Ok dismiss button.

fn button<F, S: Into<String>>(self, label: S, cb: F) -> Self where F: Fn(&mut Cursive) + 'static

Adds a button to the dialog with the given label and callback.

Consumes and returns self for easy chaining.

fn h_align(self, h: HAlign) -> Self

Sets the horizontal alignment for the buttons, if any. Only works if the buttons are as a row at the bottom of the dialog.

fn v_align(self, v: VAlign) -> Self

Sets the vertical alignment for the buttons, if any. Only works if the buttons are as a column to the right of the dialog.

fn dismiss_button<S: Into<String>>(self, label: S) -> Self

Shortcut method to add a button that will dismiss the dialog.

fn title<S: Into<String>>(self, label: S) -> Self

Sets the title of the dialog. If not empty, it will be visible at the top.

fn padding<T: Into<Vec4>>(self, padding: T) -> Self

Sets the padding in the dialog (around content and buttons).

fn padding_top(self, padding: usize) -> Self

Sets the top padding in the dialog (under the title).

fn padding_bottom(self, padding: usize) -> Self

Sets the bottom padding in the dialog (under buttons).

fn padding_left(self, padding: usize) -> Self

Sets the left padding in the dialog.

fn padding_right(self, padding: usize) -> Self

Sets the right padding in the dialog.

Trait Implementations

impl View for Dialog
[src]

fn draw(&self, printer: &Printer)

Draws the view with the given printer (includes bounds) and focus.

fn get_min_size(&mut self, req: Vec2) -> Vec2

Returns the minimum size the view requires with the given restrictions. Read more

fn layout(&mut self, size: Vec2)

Called once the size for this view has been decided, Read more

fn on_event(&mut self, event: Event) -> EventResult

Called when a key was pressed. Default implementation just ignores it.

fn take_focus(&mut self, source: Direction) -> bool

This view is offered focus. Will it take it? Read more

fn find(&mut self, selector: &Selector) -> Option<&mut Any>

Finds the view pointed to by the given path. Read more

fn needs_relayout(&self) -> bool

Returns true if the view content changed since last layout phase. Read more