summaryrefslogtreecommitdiffstats
path: root/widget
diff options
context:
space:
mode:
authorLibravatar jhannyj <jhanny@mit.edu>2024-01-25 20:55:51 -0500
committerLibravatar jhannyj <jhanny@mit.edu>2024-01-25 20:55:51 -0500
commitfeccf15e156cb615c6541fe2f444b99e885eb424 (patch)
tree9c38f8dd73564aac673b9143b1c725f6ab6752c9 /widget
parenta1114cada310fa6e4cd478cc0827500e70a1bd0d (diff)
downloadiced-feccf15e156cb615c6541fe2f444b99e885eb424.tar.gz
iced-feccf15e156cb615c6541fe2f444b99e885eb424.tar.bz2
iced-feccf15e156cb615c6541fe2f444b99e885eb424.zip
Add cut functionality to text editor
Diffstat (limited to 'widget')
-rw-r--r--widget/src/text_editor.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/widget/src/text_editor.rs b/widget/src/text_editor.rs
index c3a17bd2..354abceb 100644
--- a/widget/src/text_editor.rs
+++ b/widget/src/text_editor.rs
@@ -419,6 +419,12 @@ where
clipboard.write(selection);
}
}
+ Update::Cut => {
+ if let Some(selection) = self.content.selection() {
+ clipboard.write(selection.clone());
+ shell.publish(on_edit(Action::Edit(Edit::Delete)));
+ }
+ }
Update::Paste => {
if let Some(contents) = clipboard.read() {
shell.publish(on_edit(Action::Edit(Edit::Paste(
@@ -575,6 +581,7 @@ enum Update {
Release,
Action(Action),
Copy,
+ Cut,
Paste,
}
@@ -684,6 +691,11 @@ impl Update {
{
Some(Self::Copy)
}
+ keyboard::Key::Character("x")
+ if modifiers.command() =>
+ {
+ Some(Self::Cut)
+ }
keyboard::Key::Character("v")
if modifiers.command() && !modifiers.alt() =>
{