From c119f957eb4a75ebeecce071deecfc0f6da9d652 Mon Sep 17 00:00:00 2001 From: Tymoteusz Jankowski Date: Mon, 22 Jan 2018 19:36:10 +0100 Subject: [PATCH] Add Dialog.get_content --- src/views/dialog.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/views/dialog.rs b/src/views/dialog.rs index 17cabc8..aec1a83 100644 --- a/src/views/dialog.rs +++ b/src/views/dialog.rs @@ -103,6 +103,18 @@ impl Dialog { 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::().unwrap(); + /// assert_eq!(text_view.get_content().source(), "Hello!"); + /// ``` + pub fn get_content(&self) -> &View { + &*self.content.view + } + /// Sets the content for this dialog. /// /// Previous content will be dropped.