Where exactly in the code is the problem?
Sorry, my post wasn't clear enought.
This example I provided is supposed to change the child position from one button to the other when clicking on the "Switch Position" button. As you will see, the child window is correctly positioned under the "button1" because the button1 is children of the root. The child window doesn't position itself correctly under the button2, because the button 2 is children of another control. You will see that in that case the child window positions itself where it believes the button2 is, not taking into account the offset of the tab control.
This is the part of the code that doesn't work properly:
Sub setWindowPosition
Dim SceneX, SceneY As Double
Dim joStage, joScene As JavaObject
joStage = MainForm.RootPane
joScene = joStage.RunMethod("getScene",Null)
SceneX = joScene.RunMethod("getX", Null)
SceneY = joScene.RunMethod("getY", Null)
ChildForm.WindowLeft = MainForm.WindowLeft + CurrentButton.Left + SceneX
ChildForm.WindowWidth = MainForm.Width
ChildForm.WindowTop = MainForm.WindowTop + CurrentButton.Top + SceneY + CurrentButton.PrefHeight
End Sub
What works here is:
- the position of the window
is correct
- the offset of the scene inside the window
is correct
- the position of the button inside the scene
is correct, only for button1, but not for button2
I've done some research, and what I may have to do is to use the "parent" property of the node, and loop through all the parents of the button2 and add their left position. Is that what I should do?
There is getLocalToSceneTransform the description sounds like it may give you the figures you want.
It returns a Transform object, which appears to hold the x, y, z, scale and rotations relative to the scene.
Thanks for that, I will try to implement that. But it looks like it returns the bouding box rather that the position in the scene?
Thank you both for your help.