Skip to content

Commit

Permalink
Fix textbox mouse interaction in hidpi
Browse files Browse the repository at this point in the history
  • Loading branch information
rhelmot authored and geom3trik committed Sep 9, 2022
1 parent 1789a75 commit e37b113
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions crates/vizia_core/src/views/textbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ impl TextboxData {

// do the computation
let (mut tx, mut ty) = self.transform;
tx *= scale;
ty *= scale;
let text_box = BoundingBox { x: bounds.x + tx, y: bounds.y + ty, w: bounds.w, h: bounds.h };
if text_box.x < parent_bounds.x
&& text_box.x + text_box.w < parent_bounds.x + parent_bounds.w
Expand Down Expand Up @@ -387,8 +389,8 @@ impl Model for TextboxData {
}

TextEvent::Hit(posx, posy) => {
let posx = *posx - self.transform.0;
let posy = *posy - self.transform.1;
let posx = *posx - self.transform.0 * cx.style.dpi_factor as f32;
let posy = *posy - self.transform.1 * cx.style.dpi_factor as f32;
let idx = pos_to_idx(
posx,
posy,
Expand All @@ -401,8 +403,8 @@ impl Model for TextboxData {
}

TextEvent::Drag(posx, posy) => {
let posx = *posx - self.transform.0;
let posy = *posy - self.transform.1;
let posx = *posx - self.transform.0 * cx.style.dpi_factor as f32;
let posy = *posy - self.transform.1 * cx.style.dpi_factor as f32;
let idx = pos_to_idx(
posx,
posy,
Expand Down

0 comments on commit e37b113

Please sign in to comment.