mirror of
https://github.com/FliegendeWurst/cursive.git
synced 2024-11-23 17:35:00 +00:00
Better doc
This commit is contained in:
parent
08a935d561
commit
778c1f1d71
@ -8,6 +8,34 @@ pub trait Identifiable: View + Sized {
|
|||||||
/// Wraps this view into an `IdView` with the given id.
|
/// Wraps this view into an `IdView` with the given id.
|
||||||
///
|
///
|
||||||
/// This is just a shortcut for `IdView::new(id, self)`
|
/// This is just a shortcut for `IdView::new(id, self)`
|
||||||
|
///
|
||||||
|
/// You can use the given id to find the view in the layout tree.
|
||||||
|
///
|
||||||
|
/// # Examples
|
||||||
|
///
|
||||||
|
/// ```rust,no_run
|
||||||
|
/// let mut siv = Cursive::new();
|
||||||
|
/// siv.add_layer(
|
||||||
|
/// TextView::new("foo")
|
||||||
|
/// .with_id("text")
|
||||||
|
/// .fixed_width(10)
|
||||||
|
/// );
|
||||||
|
///
|
||||||
|
/// // You could call this from an event callback
|
||||||
|
/// siv.call_on_id("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 [`BoxView`]!
|
||||||
|
///
|
||||||
|
/// [`fixed_width`]: trait.Boxable.html#method.fixed_width
|
||||||
|
/// [`BoxView`]: ../views/struct.BoxView.html
|
||||||
|
///
|
||||||
fn with_id<S: Into<String>>(self, id: S) -> IdView<Self> {
|
fn with_id<S: Into<String>>(self, id: S) -> IdView<Self> {
|
||||||
IdView::new(id, self)
|
IdView::new(id, self)
|
||||||
}
|
}
|
||||||
|
@ -7,11 +7,16 @@ use view::{Selector, View};
|
|||||||
|
|
||||||
/// Generic wrapper around a view.
|
/// Generic wrapper around a view.
|
||||||
///
|
///
|
||||||
/// Default implementation forwards all calls to the child view.
|
/// This trait is a shortcut to implement `View` on a type by forwarding
|
||||||
/// Overrides some methods as desired.
|
/// calls to a wrapped view.
|
||||||
///
|
///
|
||||||
/// You can use the [`wrap_impl!`] macro to define `with_view` and
|
/// You only need to define `with_view` and `with_view_mut`
|
||||||
/// `with_view_mut` for you.
|
/// (the [`wrap_impl!`] macro can help you with that), and you will get
|
||||||
|
/// the `View` implementation for free.
|
||||||
|
///
|
||||||
|
/// You can also override any of the `wrap_*` methods for more specific
|
||||||
|
/// behaviors (the default implementations simply forwards the calls to the
|
||||||
|
/// child view).
|
||||||
///
|
///
|
||||||
/// [`wrap_impl!`]: ../macro.wrap_impl.html
|
/// [`wrap_impl!`]: ../macro.wrap_impl.html
|
||||||
pub trait ViewWrapper: 'static {
|
pub trait ViewWrapper: 'static {
|
||||||
|
Loading…
Reference in New Issue
Block a user