Trait HasSelectableText
pub trait HasSelectableText {
// Required methods
fn selected_text(&self, tree: &Tree) -> Option<String>;
fn select_all(&self, tree: &mut Tree);
fn is_focused(&self, tree: &Tree) -> bool;
fn context_menu_position(&self, tree: &Tree) -> Option<Point>;
fn set_context_menu_position(&self, tree: &mut Tree, pos: Option<Point>);
// Provided methods
fn is_editable(&self) -> bool { ... }
fn copy_to_clipboard(&self, tree: &Tree, clipboard: &mut dyn Clipboard) { ... }
fn delete_selection(&self, _tree: &mut Tree) -> Option<String> { ... }
fn paste_text(&self, _tree: &mut Tree, _text: &str) -> Option<String> { ... }
}Expand description
Implement this on a widget to enable context menu support for text selection (Copy, Select All, and optionally Cut / Paste) in libcosmic
Required Methods§
fn selected_text(&self, tree: &Tree) -> Option<String>
fn selected_text(&self, tree: &Tree) -> Option<String>
Returns the currently selected text, if any.
fn select_all(&self, tree: &mut Tree)
fn select_all(&self, tree: &mut Tree)
Selects all text.
fn is_focused(&self, tree: &Tree) -> bool
fn is_focused(&self, tree: &Tree) -> bool
Returns true if the widget is currently focused.
Returns the position where the context menu should appear
Sets or clears the context menu position.
Provided Methods§
fn is_editable(&self) -> bool
fn is_editable(&self) -> bool
Returns true if the widget is editable (enables Cut / Paste).
fn copy_to_clipboard(&self, tree: &Tree, clipboard: &mut dyn Clipboard)
fn copy_to_clipboard(&self, tree: &Tree, clipboard: &mut dyn Clipboard)
Copies the selection to the clipboard.
fn delete_selection(&self, _tree: &mut Tree) -> Option<String>
fn delete_selection(&self, _tree: &mut Tree) -> Option<String>
Deletes the selected text and returns the new full content.
Only called when is_editable is true.
fn paste_text(&self, _tree: &mut Tree, _text: &str) -> Option<String>
fn paste_text(&self, _tree: &mut Tree, _text: &str) -> Option<String>
Inserts text at the cursor (replacing any selection) and returns
the new full content.
Only called when is_editable is true.