From c8e70d49be12013d93ea5fbe91d57a13915195a3 Mon Sep 17 00:00:00 2001 From: Julian Winkler Date: Fri, 15 Mar 2024 17:49:40 +0100 Subject: [PATCH] implement View.getLocationOnScreen() properly --- src/api-impl/android/view/View.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/api-impl/android/view/View.java b/src/api-impl/android/view/View.java index 578325ab..dfc55e27 100644 --- a/src/api-impl/android/view/View.java +++ b/src/api-impl/android/view/View.java @@ -1040,9 +1040,11 @@ public class View extends Object { protected void onScrollChanged(int l, int t, int oldl, int oldt) {} - public void getLocationOnScreen(int[] location) { // FIXME: actually return the widget's location (and also have the onclick callback convert to window coordinates, because is seems that's what android deals in..) - location[0] = 0; - location[1] = 0; + public void getLocationOnScreen(int[] location) { + Rect rect = new Rect(); + getGlobalVisibleRect(rect); + location[0] = rect.left; + location[1] = rect.top; } public boolean performHapticFeedback(int feedbackConstant) {