[][src]Trait cursive::view::Finder

pub trait Finder {
    fn call_on<V, F, R>(&mut self, sel: &Selector, callback: F) -> Option<R>
    where
        V: View + Any,
        F: FnOnce(&mut V) -> R
; fn call_on_id<V, F, R>(&mut self, id: &str, callback: F) -> Option<R>
    where
        V: View + Any,
        F: FnOnce(&mut V) -> R
, { ... }
fn find_id<V>(&mut self, id: &str) -> Option<ViewRef<V>>
    where
        V: View + Any
, { ... } }

Provides call_on<V: View> to views.

This trait is mostly a wrapper around View::call_on_any.

It provides a nicer interface to find a view when you know its type.

Required methods

fn call_on<V, F, R>(&mut self, sel: &Selector, callback: F) -> Option<R> where
    V: View + Any,
    F: FnOnce(&mut V) -> R, 

Runs a callback on the view identified by sel.

If the view is found, return the result of callback.

If the view is not found, or if it is not of the asked type, it returns None.

Loading content...

Provided methods

fn call_on_id<V, F, R>(&mut self, id: &str, callback: F) -> Option<R> where
    V: View + Any,
    F: FnOnce(&mut V) -> R, 

Convenient method to use call_on with a view::Selector::Id.

fn find_id<V>(&mut self, id: &str) -> Option<ViewRef<V>> where
    V: View + Any

Convenient method to find a view wrapped in an IdView.

Loading content...

Implementors

impl<T: View> Finder for T[src]

fn call_on_id<V, F, R>(&mut self, id: &str, callback: F) -> Option<R> where
    V: View + Any,
    F: FnOnce(&mut V) -> R, 
[src]

fn find_id<V>(&mut self, id: &str) -> Option<ViewRef<V>> where
    V: View + Any
[src]

Loading content...