Don't paint insertion point if text is immutable (#1523)
This commit is contained in:
parent
c70c72ef61
commit
888cd9c3eb
1 changed files with 18 additions and 15 deletions
|
@ -579,6 +579,8 @@ impl<'t> TextEdit<'t> {
|
||||||
// We paint the cursor on top of the text, in case
|
// We paint the cursor on top of the text, in case
|
||||||
// the text galley has backgrounds (as e.g. `code` snippets in markup do).
|
// the text galley has backgrounds (as e.g. `code` snippets in markup do).
|
||||||
paint_cursor_selection(ui, &painter, text_draw_pos, &galley, &cursor_range);
|
paint_cursor_selection(ui, &painter, text_draw_pos, &galley, &cursor_range);
|
||||||
|
|
||||||
|
if text.is_mutable() {
|
||||||
let cursor_pos = paint_cursor_end(
|
let cursor_pos = paint_cursor_end(
|
||||||
ui,
|
ui,
|
||||||
row_height,
|
row_height,
|
||||||
|
@ -592,7 +594,7 @@ impl<'t> TextEdit<'t> {
|
||||||
ui.scroll_to_rect(cursor_pos, None); // keep cursor in view
|
ui.scroll_to_rect(cursor_pos, None); // keep cursor in view
|
||||||
}
|
}
|
||||||
|
|
||||||
if interactive && text.is_mutable() {
|
if interactive {
|
||||||
// egui_web uses `text_cursor_pos` when showing IME,
|
// egui_web uses `text_cursor_pos` when showing IME,
|
||||||
// so only set it when text is editable and visible!
|
// so only set it when text is editable and visible!
|
||||||
ui.ctx().output().text_cursor_pos = Some(cursor_pos.left_top());
|
ui.ctx().output().text_cursor_pos = Some(cursor_pos.left_top());
|
||||||
|
@ -600,6 +602,7 @@ impl<'t> TextEdit<'t> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
state.clone().store(ui.ctx(), id);
|
state.clone().store(ui.ctx(), id);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue