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
Actionnable button with a label.
Subtree
Fields
Sub-menu with a label.
Delimiter
Delimiter without a label.
Implementations§
source§impl Item
impl Item
sourcepub fn leaf<S, F>(label: S, cb: F) -> Selfwhere
S: Into<String>,
F: 'static + Fn(&mut Cursive),
pub fn leaf<S, F>(label: S, cb: F) -> Selfwhere
S: Into<String>,
F: 'static + Fn(&mut Cursive),
Create a new leaf menu item.
sourcepub fn subtree<S>(label: S, tree: Tree) -> Selfwhere
S: Into<String>,
pub fn subtree<S>(label: S, tree: Tree) -> Selfwhere
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
.