D daxydoggie Member Licensed User Longtime User Aug 1, 2015 #1 Hi, Is there an iOS (or B4i) version of https://www.b4x.com/android/forum/t...ates-of-view-using-getlocationonscreen.54020/ in order to find the location of a view in relation to the visible page/screen (not its parent). Thanks, Craig.
Hi, Is there an iOS (or B4i) version of https://www.b4x.com/android/forum/t...ates-of-view-using-getlocationonscreen.54020/ in order to find the location of a view in relation to the visible page/screen (not its parent). Thanks, Craig.
Erel B4X founder Staff member Licensed User Longtime User Aug 2, 2015 #2 You can use this code: Code: Copy Sub GetPageLeftAndTop(v As View) As Float() Dim tl(2) As Float Do While GetType(v) <> "B4IMainView" Dim no As NativeObject = v tl(0) = tl(0) + v.Left tl(1) = tl(1) + v.Top v = no.GetField("superview") Loop Return tl End Sub Code: Copy Dim LeftTop() As Float = GetPageLeftAndTop(Button1) Log($"Left: ${LeftTop(0)} Top: ${LeftTop(1)}"$) Upvote 0
You can use this code: Code: Copy Sub GetPageLeftAndTop(v As View) As Float() Dim tl(2) As Float Do While GetType(v) <> "B4IMainView" Dim no As NativeObject = v tl(0) = tl(0) + v.Left tl(1) = tl(1) + v.Top v = no.GetField("superview") Loop Return tl End Sub Code: Copy Dim LeftTop() As Float = GetPageLeftAndTop(Button1) Log($"Left: ${LeftTop(0)} Top: ${LeftTop(1)}"$)