A simple form with a button.
The mouse clicked sub:
The buttons new position:
The log output:
Looks to me like Left is using getLayoutX() (and possibly + getLayoutBounds().getMinX()) not getLayoutX() + getTranslateX() + getLayoutBounds().getMinX() for the Left property. The same applies to the Top property.
Changing the sub to:
gives me
The mouse clicked sub:
B4X:
Sub B1_MouseClicked(EventData As MouseEvent)
Dim R As Reflector
Log("Left Before Translate: " & Button1.Left)
R.Target = Button1
R.RunMethod2("setTranslateX","480","java.lang.double")
Log("Left After Translate: " & Button1.Left)
End Sub
The buttons new position:
The log output:
B4X:
Waiting for debugger to connect...
Program started.
Left Before Translate: 10
Left After Translate: 10
Looks to me like Left is using getLayoutX() (and possibly + getLayoutBounds().getMinX()) not getLayoutX() + getTranslateX() + getLayoutBounds().getMinX() for the Left property. The same applies to the Top property.
Changing the sub to:
B4X:
Sub B1_MouseClicked(EventData As MouseEvent)
Dim R As Reflector
Log("Left Before Translate: " & Button1.Left)
R.Target = Button1
R.RunMethod2("setTranslateX","480","java.lang.double")
Log("Left After Translate: " & Button1.Left)
Log("Layout X: " & R.RunMethod("getLayoutX"))
Log("Translate X: " & R.RunMethod("getTranslateX"))
R.Target = R.RunMethod("getLayoutBounds")
Log("Bounds MinX: " & R.RunMethod("getMinX"))
End Sub
gives me
B4X:
Left Before Translate: 10
Left After Translate: 10
Layout X: 10.0
Translate X: 480.0
Bounds MinX: 0.0