mirror of
https://github.com/emilk/egui.git
synced 2026-08-29 04:40:03 -04:00
✋ egui_winit: Allow getting the clipboard and allow_ime state (#3724)
The `egui_winit::State` contains both the `clipboard` and `allow_ime`, but these are both private fields. In our implementation we use `egui_winit` to do most of the lifting, but it would come really in handy if we could access these values. Instead of making the fields `pub` we opted for separate get/set functions, that way calling side can't freely replace any of the values fully and it's more in line with the style of the rest of the codebase. --------- Co-authored-by: Marijn Suijten <marijn@traverseresearch.nl> Co-authored-by: Marijn Suijten <marijns95@gmail.com>
This commit is contained in:
@@ -174,6 +174,26 @@ impl State {
|
||||
self.egui_input.max_texture_side = Some(max_texture_side);
|
||||
}
|
||||
|
||||
/// Fetches text from the clipboard and returns it.
|
||||
pub fn clipboard_text(&mut self) -> Option<String> {
|
||||
self.clipboard.get()
|
||||
}
|
||||
|
||||
/// Places the text onto the clipboard.
|
||||
pub fn set_clipboard_text(&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.
|
||||
pub fn allow_ime(&self) -> bool {
|
||||
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]
|
||||
pub fn egui_ctx(&self) -> &egui::Context {
|
||||
&self.egui_ctx
|
||||
|
||||
Reference in New Issue
Block a user