Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only show on-screen-keyboard and IME when editing text #3362

Merged
merged 6 commits into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions crates/eframe/src/native/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,6 @@ mod glow_integration {
let theme = system_theme.unwrap_or(self.native_options.default_theme);
integration.egui_ctx.set_visuals(theme.egui_visuals());

gl_window.window().set_ime_allowed(true);
if self.native_options.mouse_passthrough {
gl_window.window().set_cursor_hittest(false).unwrap();
}
Expand Down Expand Up @@ -1269,8 +1268,6 @@ mod wgpu_integration {
let theme = system_theme.unwrap_or(self.native_options.default_theme);
integration.egui_ctx.set_visuals(theme.egui_visuals());

window.set_ime_allowed(true);

{
let event_loop_proxy = self.repaint_proxy.clone();
integration
Expand Down
10 changes: 10 additions & 0 deletions crates/egui-winit/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ pub struct State {

#[cfg(feature = "accesskit")]
accesskit: Option<accesskit_winit::Adapter>,

allow_ime: bool,
}

impl State {
Expand Down Expand Up @@ -107,6 +109,8 @@ impl State {

#[cfg(feature = "accesskit")]
accesskit: None,

allow_ime: false,
}
}

Expand Down Expand Up @@ -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 });
}
Expand Down
Loading