From f0fc43428ed641fbeff0b38148443318058f6622 Mon Sep 17 00:00:00 2001 From: tosti007 Date: Wed, 20 Dec 2023 12:07:03 +0100 Subject: [PATCH 1/5] Allow getting the clipboard and allow_ime state Co-authored-by: Marijn Suijten --- crates/egui-winit/src/lib.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/crates/egui-winit/src/lib.rs b/crates/egui-winit/src/lib.rs index 3da3781e093..c416e658c63 100644 --- a/crates/egui-winit/src/lib.rs +++ b/crates/egui-winit/src/lib.rs @@ -172,6 +172,21 @@ impl State { self.egui_input.max_texture_side = Some(max_texture_side); } + /// Returns the used clipboard. + pub fn clipboard(&mut self) -> &mut clipboard::Clipboard { + &mut self.clipboard + } + + /// Returns [`false`] or the last value that [`Window::set_ime_allowed()`] was called with, used for debouncing. + pub fn allow_ime(&self) -> bool { + self.allow_ime + } + + /// Returns [`false`] or the last value that [`Window::set_ime_allowed()`] was called with, used for debouncing. + pub fn allow_ime_mut(&mut self) -> &mut bool { + &mut self.allow_ime + } + #[inline] pub fn egui_ctx(&self) -> &egui::Context { &self.egui_ctx From 4d1581a36624d4b226cc56f7d63aebf9c11ad321 Mon Sep 17 00:00:00 2001 From: Brian Janssen Date: Tue, 9 Jan 2024 10:19:59 +0100 Subject: [PATCH 2/5] Accept @MarijnS95's suggestion Co-authored-by: Marijn Suijten --- crates/egui-winit/src/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/egui-winit/src/lib.rs b/crates/egui-winit/src/lib.rs index c416e658c63..65fc03127f9 100644 --- a/crates/egui-winit/src/lib.rs +++ b/crates/egui-winit/src/lib.rs @@ -182,9 +182,9 @@ impl State { self.allow_ime } - /// Returns [`false`] or the last value that [`Window::set_ime_allowed()`] was called with, used for debouncing. - pub fn allow_ime_mut(&mut self) -> &mut bool { - &mut self.allow_ime + /// Set the last value that [`Window::set_ime_allowed()`] was called with. + pub fn set_allow_ime(&mut self, allow: bool) { + self.allow_ime = allow; } #[inline] From e083d88921df5bd2d046b60c8bc6eea696944cd0 Mon Sep 17 00:00:00 2001 From: tosti007 Date: Tue, 9 Jan 2024 10:22:25 +0100 Subject: [PATCH 3/5] Split clipboard into clipboard and set_clipboard --- crates/egui-winit/src/lib.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/crates/egui-winit/src/lib.rs b/crates/egui-winit/src/lib.rs index 65fc03127f9..ab655714142 100644 --- a/crates/egui-winit/src/lib.rs +++ b/crates/egui-winit/src/lib.rs @@ -172,9 +172,14 @@ impl State { self.egui_input.max_texture_side = Some(max_texture_side); } - /// Returns the used clipboard. - pub fn clipboard(&mut self) -> &mut clipboard::Clipboard { - &mut self.clipboard + /// Fetches text from the clipboard and returns it. + pub fn clipboard(&mut self) -> Option { + self.clipboard.get() + } + + /// Places the text onto the clipboard. + pub fn set_clipboard(&mut self, text: String) { + self.clipboard.set(text) } /// Returns [`false`] or the last value that [`Window::set_ime_allowed()`] was called with, used for debouncing. From 28365a385d4e83a49ae8fd76f108e078a0eb400d Mon Sep 17 00:00:00 2001 From: tosti007 Date: Tue, 9 Jan 2024 10:30:01 +0100 Subject: [PATCH 4/5] Add '_text' suffix to clipboard functions Co-authored-by: Marijn Suijten --- crates/egui-winit/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/egui-winit/src/lib.rs b/crates/egui-winit/src/lib.rs index ab655714142..50adcb115ef 100644 --- a/crates/egui-winit/src/lib.rs +++ b/crates/egui-winit/src/lib.rs @@ -173,12 +173,12 @@ impl State { } /// Fetches text from the clipboard and returns it. - pub fn clipboard(&mut self) -> Option { + pub fn clipboard_text(&mut self) -> Option { self.clipboard.get() } /// Places the text onto the clipboard. - pub fn set_clipboard(&mut self, text: String) { + pub fn set_clipboard_text(&mut self, text: String) { self.clipboard.set(text) } From 4e13736fdd3851c549bd73d181415834e3c8eab9 Mon Sep 17 00:00:00 2001 From: tosti007 Date: Tue, 9 Jan 2024 13:33:23 +0100 Subject: [PATCH 5/5] Formatting requirements --- crates/egui-winit/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/egui-winit/src/lib.rs b/crates/egui-winit/src/lib.rs index 50adcb115ef..15924eca8e2 100644 --- a/crates/egui-winit/src/lib.rs +++ b/crates/egui-winit/src/lib.rs @@ -179,7 +179,7 @@ impl State { /// Places the text onto the clipboard. pub fn set_clipboard_text(&mut self, text: String) { - self.clipboard.set(text) + self.clipboard.set(text); } /// Returns [`false`] or the last value that [`Window::set_ime_allowed()`] was called with, used for debouncing.