mirror of
https://github.com/emilk/egui.git
synced 2026-08-30 13:20:05 -04:00
Move IME candidate window following text cursor (#258)
* egui_web: enable IME support on web. * Move candidate window following text cursor. * Preclude too frequent agent movement. * IME candidate window move on native app.
This commit is contained in:
@@ -212,7 +212,7 @@ pub fn run(mut app: Box<dyn epi::App>) -> ! {
|
||||
|
||||
set_cursor_icon(&display, egui_output.cursor_icon);
|
||||
current_cursor_icon = egui_output.cursor_icon;
|
||||
handle_output(egui_output, clipboard.as_mut());
|
||||
handle_output(egui_output, clipboard.as_mut(), &display);
|
||||
|
||||
// TODO: handle app_output
|
||||
// eprintln!("Warmed up in {} ms", warm_up_start.elapsed().as_millis())
|
||||
@@ -289,7 +289,7 @@ pub fn run(mut app: Box<dyn epi::App>) -> ! {
|
||||
set_cursor_icon(&display, egui_output.cursor_icon);
|
||||
current_cursor_icon = egui_output.cursor_icon;
|
||||
}
|
||||
handle_output(egui_output, clipboard.as_mut());
|
||||
handle_output(egui_output, clipboard.as_mut(), &display);
|
||||
|
||||
#[cfg(feature = "persistence")]
|
||||
if let Some(storage) = &mut storage {
|
||||
|
||||
@@ -303,7 +303,11 @@ fn set_cursor_icon(display: &glium::backend::glutin::Display, cursor_icon: egui:
|
||||
}
|
||||
}
|
||||
|
||||
pub fn handle_output(output: egui::Output, clipboard: Option<&mut ClipboardContext>) {
|
||||
pub fn handle_output(
|
||||
output: egui::Output,
|
||||
clipboard: Option<&mut ClipboardContext>,
|
||||
display: &glium::Display,
|
||||
) {
|
||||
if let Some(open) = output.open_url {
|
||||
if let Err(err) = webbrowser::open(&open.url) {
|
||||
eprintln!("Failed to open url: {}", err);
|
||||
@@ -317,6 +321,13 @@ pub fn handle_output(output: egui::Output, clipboard: Option<&mut ClipboardConte
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(egui::Pos2 { x, y }) = output.text_cursor {
|
||||
display
|
||||
.gl_window()
|
||||
.window()
|
||||
.set_ime_position(glium::glutin::dpi::LogicalPosition { x, y })
|
||||
}
|
||||
}
|
||||
|
||||
pub fn init_clipboard() -> Option<ClipboardContext> {
|
||||
|
||||
Reference in New Issue
Block a user