Преглед изворни кода

wallet: ignore touch events outside widget rects

darkfi пре 2 година
родитељ
комит
830ec00e0d
2 измењених фајлова са 16 додато и 0 уклоњено
  1. 8 0
      bin/darkwallet/src/ui/button.rs
  2. 8 0
      bin/darkwallet/src/ui/chatview.rs

+ 8 - 0
bin/darkwallet/src/ui/button.rs

@@ -199,6 +199,14 @@ impl Button {
         if id != 0 {
             return
         }
+
+        let Some(rect) = self.get_cached_rect() else { return };
+        let touch_pos = Point { x: touch_x, y: touch_y };
+        if !rect.contains(&touch_pos) {
+            //debug!(target: "ui::chatview", "not inside rect");
+            return
+        }
+
         // Simulate mouse events
         match phase {
             TouchPhase::Started => self.handle_mouse_btn_down(MouseButton::Left, touch_x, touch_y),

+ 8 - 0
bin/darkwallet/src/ui/chatview.rs

@@ -588,6 +588,14 @@ impl ChatView {
         if id != 0 {
             return
         }
+
+        let Some(rect) = self.get_cached_world_rect().await else { return };
+        let touch_pos = Point { x: touch_x, y: touch_y };
+        if !rect.contains(&touch_pos) {
+            //debug!(target: "ui::chatview", "not inside rect");
+            return
+        }
+
         // Simulate mouse events
         match phase {
             TouchPhase::Started => {