mirror of
https://github.com/emilk/egui.git
synced 2026-08-30 13:20:05 -04:00
Rename Output::text_cursor to text_cursor_pos
This commit is contained in:
@@ -141,7 +141,7 @@ pub struct AppRunner {
|
||||
screen_reader: crate::screen_reader::ScreenReader,
|
||||
#[cfg(feature = "http")]
|
||||
http: Arc<http::WebHttp>,
|
||||
pub(crate) text_cursor: Option<egui::Pos2>,
|
||||
pub(crate) last_text_cursor_pos: Option<egui::Pos2>,
|
||||
}
|
||||
|
||||
impl AppRunner {
|
||||
@@ -160,7 +160,7 @@ impl AppRunner {
|
||||
screen_reader: Default::default(),
|
||||
#[cfg(feature = "http")]
|
||||
http: Arc::new(http::WebHttp {}),
|
||||
text_cursor: None,
|
||||
last_text_cursor_pos: None,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -299,7 +299,7 @@ pub fn handle_output(output: &egui::Output, runner: &mut AppRunner) {
|
||||
copied_text,
|
||||
needs_repaint: _, // handled elsewhere
|
||||
events: _, // we ignore these (TODO: accessibility screen reader)
|
||||
text_cursor: cursor,
|
||||
text_cursor_pos,
|
||||
} = output;
|
||||
|
||||
set_cursor_icon(*cursor_icon);
|
||||
@@ -315,9 +315,9 @@ pub fn handle_output(output: &egui::Output, runner: &mut AppRunner) {
|
||||
#[cfg(not(web_sys_unstable_apis))]
|
||||
let _ = copied_text;
|
||||
|
||||
if &runner.text_cursor != cursor {
|
||||
move_text_cursor(cursor, runner.canvas_id());
|
||||
runner.text_cursor = *cursor;
|
||||
if &runner.last_text_cursor_pos != text_cursor_pos {
|
||||
move_text_cursor(text_cursor_pos, runner.canvas_id());
|
||||
runner.last_text_cursor_pos = *text_cursor_pos;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1119,12 +1119,13 @@ fn is_mobile() -> Option<bool> {
|
||||
Some(is_mobile)
|
||||
}
|
||||
|
||||
// Move angnt to text cursor's position, on desktop/laptop, candidate window moves following text elemt(agent),
|
||||
// Move text agent to text cursor's position, on desktop/laptop,
|
||||
// candidate window moves following text element (agent),
|
||||
// so it appears that the IME candidate window moves with text cursor.
|
||||
// On mobile devices, there is no need to do that.
|
||||
fn move_text_cursor(cursor: &Option<egui::Pos2>, canvas_id: &str) -> Option<()> {
|
||||
let style = text_agent().style();
|
||||
// Note: movint agent on mobile devices will lead to unpreditable scroll.
|
||||
// Note: movint agent on mobile devices will lead to unpredictable scroll.
|
||||
if is_mobile() == Some(false) {
|
||||
cursor.as_ref().and_then(|&egui::Pos2 { x, y }| {
|
||||
let canvas = canvas_element(canvas_id)?;
|
||||
|
||||
Reference in New Issue
Block a user