pub enum ContextMenuEntry {
Item(ContextMenuItem),
Separator,
}Expand description
A custom editor context-menu entry.
Pass a list of these to CodeEditor::set_custom_context_menu_entries to
extend the menu, or to replace it entirely by also turning off the built-in
actions with CodeEditor::set_default_context_menu_enabled.
§Examples
use iced_code_editor::ContextMenuEntry;
let entries = vec![
ContextMenuEntry::item("format", "Format Document")
.with_shortcut("Ctrl+Shift+F"),
ContextMenuEntry::separator(),
ContextMenuEntry::item("rename", "Rename Symbol").with_enabled(false),
];
assert_eq!(entries.len(), 3);Variants§
Item(ContextMenuItem)
An actionable menu item.
Separator
A visual separator between groups of items.
Implementations§
Source§impl ContextMenuEntry
impl ContextMenuEntry
Sourcepub fn item(id: impl Into<String>, label: impl Into<String>) -> Self
pub fn item(id: impl Into<String>, label: impl Into<String>) -> Self
Creates an enabled action entry without a shortcut hint.
Shorthand for wrapping ContextMenuItem::new.
§Arguments
id- Stable action identifier emitted when the entry is selectedlabel- The text shown to the user
§Returns
An ContextMenuEntry::Item wrapping a new enabled item
§Examples
use iced_code_editor::{ContextMenuEntry, ContextMenuItem};
let entry = ContextMenuEntry::item("format", "Format Document");
assert_eq!(
entry,
ContextMenuEntry::Item(ContextMenuItem::new("format", "Format Document")),
);Sourcepub const fn separator() -> Self
pub const fn separator() -> Self
Sourcepub fn with_shortcut(self, shortcut: impl Into<String>) -> Self
pub fn with_shortcut(self, shortcut: impl Into<String>) -> Self
Sets the keyboard shortcut hint when this is an action entry.
A separator has no shortcut to set, so it is returned unchanged rather than erroring — this keeps a chain of builder calls over a mixed list of entries free of special cases.
§Arguments
shortcut- The shortcut text to display, e.g.Ctrl+Shift+F
§Returns
Self for method chaining
§Examples
use iced_code_editor::ContextMenuEntry;
let entry = ContextMenuEntry::item("format", "Format Document")
.with_shortcut("Ctrl+Shift+F");
assert!(matches!(entry, ContextMenuEntry::Item(_)));
// A separator is unaffected.
let separator = ContextMenuEntry::separator().with_shortcut("Ctrl+K");
assert_eq!(separator, ContextMenuEntry::Separator);Sourcepub fn with_enabled(self, enabled: bool) -> Self
pub fn with_enabled(self, enabled: bool) -> Self
Sets whether this entry can be selected when it is an action.
A separator is returned unchanged, for the same reason as
Self::with_shortcut.
§Arguments
enabled- Whether the entry can be selected
§Returns
Self for method chaining
§Examples
use iced_code_editor::{ContextMenuEntry, ContextMenuItem};
let entry = ContextMenuEntry::item("rename", "Rename Symbol")
.with_enabled(false);
assert_eq!(
entry,
ContextMenuEntry::Item(
ContextMenuItem::new("rename", "Rename Symbol").with_enabled(false)
),
);
// A separator is unaffected.
let separator = ContextMenuEntry::separator().with_enabled(false);
assert_eq!(separator, ContextMenuEntry::Separator);Trait Implementations§
Source§impl Clone for ContextMenuEntry
impl Clone for ContextMenuEntry
Source§fn clone(&self) -> ContextMenuEntry
fn clone(&self) -> ContextMenuEntry
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ContextMenuEntry
impl Debug for ContextMenuEntry
impl Eq for ContextMenuEntry
Source§impl From<ContextMenuItem> for ContextMenuEntry
impl From<ContextMenuItem> for ContextMenuEntry
Source§fn from(item: ContextMenuItem) -> Self
fn from(item: ContextMenuItem) -> Self
Source§impl PartialEq for ContextMenuEntry
impl PartialEq for ContextMenuEntry
impl StructuralPartialEq for ContextMenuEntry
Auto Trait Implementations§
impl Freeze for ContextMenuEntry
impl RefUnwindSafe for ContextMenuEntry
impl Send for ContextMenuEntry
impl Sync for ContextMenuEntry
impl Unpin for ContextMenuEntry
impl UnsafeUnpin for ContextMenuEntry
impl UnwindSafe for ContextMenuEntry
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<State, Message> IntoBoot<State, Message> for State
impl<State, Message> IntoBoot<State, Message> for State
Source§fn into_boot(self) -> (State, Task<Message>)
fn into_boot(self) -> (State, Task<Message>)
Application.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more