Skip to content

Commit

Permalink
Fix a display problem when entering text after the size of TextEdit e…
Browse files Browse the repository at this point in the history
…xtends off the screen on the web
  • Loading branch information
sumibi-yakitori committed Oct 21, 2021
1 parent 19766bf commit a861b1e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions egui_web/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1225,8 +1225,12 @@ fn move_text_cursor(cursor: &Option<egui::Pos2>, canvas_id: &str) -> Option<()>
if is_mobile() == Some(false) {
cursor.as_ref().and_then(|&egui::Pos2 { x, y }| {
let canvas = canvas_element(canvas_id)?;
let y = y + (canvas.scroll_top() + canvas.offset_top()) as f32;
let x = x + (canvas.scroll_left() + canvas.offset_left()) as f32;
// If you enable the lines after
// After entering a new line so that the height of TextEdit exceeds the height of the browser window,
// if you enter any text, the egui screen will be driven outside the client area.
// let y = y + (canvas.scroll_top() + canvas.offset_top()) as f32;
// let x = x + (canvas.scroll_left() + canvas.offset_left()) as f32;

// Canvas is translated 50% horizontally in html.
let x = x - canvas.offset_width() as f32 / 2.0;
style.set_property("position", "absolute").ok()?;
Expand Down

0 comments on commit a861b1e

Please sign in to comment.