mirror of
https://github.com/emilk/egui.git
synced 2026-09-02 06:40:06 -04:00
Only show on-screen-keyboard and IME when editing text (#3362)
* Remove calls to `set_ime_allowed` * Allow IME if `text_cursor_pos` is `Some` * Only call `Window::set_ime_allowed` when necessary * allow_ime doesn't need to be atomic * Remove unused imports * Fix assignment
This commit is contained in:
@@ -80,6 +80,8 @@ pub struct State {
|
||||
|
||||
#[cfg(feature = "accesskit")]
|
||||
accesskit: Option<accesskit_winit::Adapter>,
|
||||
|
||||
allow_ime: bool,
|
||||
}
|
||||
|
||||
impl State {
|
||||
@@ -107,6 +109,8 @@ impl State {
|
||||
|
||||
#[cfg(feature = "accesskit")]
|
||||
accesskit: None,
|
||||
|
||||
allow_ime: false,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -663,6 +667,12 @@ impl State {
|
||||
self.clipboard.set(copied_text);
|
||||
}
|
||||
|
||||
let allow_ime = text_cursor_pos.is_some();
|
||||
if self.allow_ime != allow_ime {
|
||||
self.allow_ime = allow_ime;
|
||||
window.set_ime_allowed(allow_ime);
|
||||
}
|
||||
|
||||
if let Some(egui::Pos2 { x, y }) = text_cursor_pos {
|
||||
window.set_ime_position(winit::dpi::LogicalPosition { x, y });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user