Enum cursive_core::menu::Item
source · [−]pub enum Item {
Leaf {
label: String,
cb: Callback,
enabled: bool,
},
Subtree {
label: String,
tree: Rc<Tree>,
enabled: bool,
},
Delimiter,
}
Expand description
Node in the menu tree.
Variants
Leaf
Fields
label: String
Text displayed for this entry.
cb: Callback
Callback to run when the entry is selected.
enabled: bool
Whether this item is enabled.
Disabled items cannot be selected and are displayed grayed out.
Actionnable button with a label.
Subtree
Fields
label: String
Text displayed for this entry.
enabled: bool
Whether this item is enabled.
Disabled items cannot be selected and are displayed grayed out.
Sub-menu with a label.
Delimiter
Delimiter without a label.
Implementations
sourceimpl Item
impl Item
sourcepub fn leaf<S, F>(label: S, cb: F) -> Self where
S: Into<String>,
F: 'static + Fn(&mut Cursive),
pub fn leaf<S, F>(label: S, cb: F) -> Self where
S: Into<String>,
F: 'static + Fn(&mut Cursive),
Create a new leaf menu item.
sourcepub fn subtree<S>(label: S, tree: Tree) -> Self where
S: Into<String>,
pub fn subtree<S>(label: S, tree: Tree) -> Self where
S: Into<String>,
Create a new subtree menu item.
sourcepub fn label(&self) -> &str
pub fn label(&self) -> &str
Returns the label for this item.
Returns a vertical bar string if self
is a delimiter.
sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
Returns true if this item is enabled.
Only labels and subtrees can be enabled. Delimiters
sourcepub fn disable(&mut self)
pub fn disable(&mut self)
Disable this item.
Disabled items cannot be selected and are shown grayed out.
Does not affect delimiters.
sourcepub fn is_delimiter(&self) -> bool
pub fn is_delimiter(&self) -> bool
Returns true
if self
is a delimiter.
sourcepub fn is_subtree(&self) -> bool
pub fn is_subtree(&self) -> bool
Returns true
if self
is a subtree.
sourcepub fn as_subtree(&mut self) -> Option<&mut Tree>
pub fn as_subtree(&mut self) -> Option<&mut Tree>
Return a mutable reference to the subtree, if applicable.
Returns None
if self
is not a Item::Subtree
.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Item
impl !Send for Item
impl !Sync for Item
impl Unpin for Item
impl !UnwindSafe for Item
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more