Merge pull request #190 from xliiv/dialog-content-get

Add get_content on Dialog
This commit is contained in:
Alexandre Bury 2018-01-22 13:18:08 -08:00 committed by GitHub
commit 8aa901afb4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -103,6 +103,18 @@ impl Dialog {
self.with(|s| s.set_content(view)) self.with(|s| s.set_content(view))
} }
/// 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(&self) -> &View {
&*self.content.view
}
/// Sets the content for this dialog. /// Sets the content for this dialog.
/// ///
/// Previous content will be dropped. /// Previous content will be dropped.