Просмотр исходного кода

app/ui/button: add `handle_touch_sync()` impl

Missing this method was causing the bottom buttons (wallet and write) on the menu screen to be untappable on android. `handle_touch_sync()` is checked before `handle_touch()` so the menu behind the buttons was swallowing the touch start events meant for the buttons.
epiphany 2 месяцев назад
Родитель
Сommit
853178320c
1 измененных файлов с 27 добавлено и 1 удалено
  1. 27 1
      bin/app/src/ui/button.rs

+ 27 - 1
bin/app/src/ui/button.rs

@@ -26,7 +26,7 @@ use std::sync::{
 use tracing::instrument;
 use tracing::instrument;
 
 
 use crate::{
 use crate::{
-    gfx::{gfxtag, DrawCall, DrawInstruction, DrawMesh, Point, Rectangle, RenderApi, Renderer},
+    gfx::{gfxtag, DrawCall, DrawInstruction, DrawMesh, Point, Rectangle, RenderApi, Renderer, RendererSync},
     mesh::MeshBuilder,
     mesh::MeshBuilder,
     prop::{PropertyAtomicGuard, PropertyBool, PropertyRect, PropertyUint32, Role},
     prop::{PropertyAtomicGuard, PropertyBool, PropertyRect, PropertyUint32, Role},
     scene::{Pimpl, SceneNodeWeak},
     scene::{Pimpl, SceneNodeWeak},
@@ -188,6 +188,32 @@ impl UIObject for Button {
             TouchPhase::Cancelled => false,
             TouchPhase::Cancelled => false,
         }
         }
     }
     }
+
+    fn handle_touch_sync(&self, _renderer: &RendererSync, phase: TouchPhase, id: u64, touch_pos: Point) -> bool {
+        if !self.is_active.get() {
+            return false
+        }
+
+        // Ignore multi-touch
+        if id != 0 {
+            return false
+        }
+
+        let rect = self.rect.get();
+        if !rect.contains(touch_pos) {
+            return false
+        }
+
+        match phase {
+            TouchPhase::Started => {
+                self.mouse_btn_held.store(true, Ordering::Relaxed);
+                true
+            },
+            TouchPhase::Moved => false,
+            TouchPhase::Ended => false,
+            TouchPhase::Cancelled => false,
+        }
+    }
 }
 }
 
 
 impl std::fmt::Debug for Button {
 impl std::fmt::Debug for Button {