[][src]Trait cursive::traits::Nameable

pub trait Nameable: View {
    fn with_name<S>(self, name: S) -> NamedView<Self>
    where
        S: Into<String>
, { ... }
fn with_id<S>(self, id: S) -> NamedView<Self>
    where
        S: Into<String>
, { ... } }

Makes a view wrappable in an NamedView.

Provided methods

fn with_name<S>(self, name: S) -> NamedView<Self> where
    S: Into<String>, 

Wraps this view into an NamedView with the given id.

This is just a shortcut for NamedView::new(id, self)

You can use the given id to find the view in the layout tree.

Examples

use cursive_core::view::Nameable;

let mut siv = Cursive::dummy();
siv.add_layer(
    TextView::new("foo")
        .with_name("text")
        .fixed_width(10)
);

// You could call this from an event callback
siv.call_on_name("text", |view: &mut TextView| {
    view.set_content("New content!");
});

Notes

You should call this directly on the view you want to retrieve later, before other wrappers like fixed_width. Otherwise, you would be retrieving a ResizedView!

fn with_id<S>(self, id: S) -> NamedView<Self> where
    S: Into<String>, 

👎 Deprecated:

with_id is being renamed to with_name

Same as with_name

Loading content...

Implementors

impl<T> Nameable for T where
    T: View
[src]

Any View implements this trait.

Loading content...