summaryrefslogtreecommitdiffstats
path: root/widget/src
diff options
context:
space:
mode:
Diffstat (limited to 'widget/src')
-rw-r--r--widget/src/text_editor.rs11
-rw-r--r--widget/src/text_input.rs19
2 files changed, 19 insertions, 11 deletions
diff --git a/widget/src/text_editor.rs b/widget/src/text_editor.rs
index cbcab1eb..50f7fabb 100644
--- a/widget/src/text_editor.rs
+++ b/widget/src/text_editor.rs
@@ -1,4 +1,5 @@
//! Display a multi-line text input for text editing.
+use crate::core::clipboard::{self, Clipboard};
use crate::core::event::{self, Event};
use crate::core::keyboard;
use crate::core::keyboard::key;
@@ -10,7 +11,7 @@ use crate::core::text::highlighter::{self, Highlighter};
use crate::core::text::{self, LineHeight};
use crate::core::widget::{self, Widget};
use crate::core::{
- Clipboard, Element, Length, Padding, Pixels, Rectangle, Shell, Size, Vector,
+ Element, Length, Padding, Pixels, Rectangle, Shell, Size, Vector,
};
use std::cell::RefCell;
@@ -448,17 +449,19 @@ where
}
Update::Copy => {
if let Some(selection) = self.content.selection() {
- clipboard.write(selection);
+ clipboard.write(clipboard::Kind::Standard, selection);
}
}
Update::Cut => {
if let Some(selection) = self.content.selection() {
- clipboard.write(selection.clone());
+ clipboard.write(clipboard::Kind::Standard, selection);
shell.publish(on_edit(Action::Edit(Edit::Delete)));
}
}
Update::Paste => {
- if let Some(contents) = clipboard.read() {
+ if let Some(contents) =
+ clipboard.read(clipboard::Kind::Standard)
+ {
shell.publish(on_edit(Action::Edit(Edit::Paste(
Arc::new(contents),
))));
diff --git a/widget/src/text_input.rs b/widget/src/text_input.rs
index 0a7ed014..f5b57422 100644
--- a/widget/src/text_input.rs
+++ b/widget/src/text_input.rs
@@ -12,6 +12,7 @@ pub use value::Value;
use editor::Editor;
use crate::core::alignment;
+use crate::core::clipboard::{self, Clipboard};
use crate::core::event::{self, Event};
use crate::core::keyboard;
use crate::core::keyboard::key;
@@ -26,8 +27,8 @@ use crate::core::widget::operation::{self, Operation};
use crate::core::widget::tree::{self, Tree};
use crate::core::window;
use crate::core::{
- Clipboard, Element, Layout, Length, Padding, Pixels, Point, Rectangle,
- Shell, Size, Vector, Widget,
+ Element, Layout, Length, Padding, Pixels, Point, Rectangle, Shell, Size,
+ Vector, Widget,
};
use crate::runtime::Command;
@@ -864,8 +865,10 @@ where
if let Some((start, end)) =
state.cursor.selection(value)
{
- clipboard
- .write(value.select(start, end).to_string());
+ clipboard.write(
+ clipboard::Kind::Standard,
+ value.select(start, end).to_string(),
+ );
}
}
keyboard::Key::Character("x")
@@ -874,8 +877,10 @@ where
if let Some((start, end)) =
state.cursor.selection(value)
{
- clipboard
- .write(value.select(start, end).to_string());
+ clipboard.write(
+ clipboard::Kind::Standard,
+ value.select(start, end).to_string(),
+ );
}
let mut editor = Editor::new(value, &mut state.cursor);
@@ -894,7 +899,7 @@ where
Some(content) => content,
None => {
let content: String = clipboard
- .read()
+ .read(clipboard::Kind::Standard)
.unwrap_or_default()
.chars()
.filter(|c| !c.is_control())