Is there a way to get position of nested child? I ...
# compose-desktop
m
Is there a way to get position of nested child? I want to draw edges between nodes on different handlers when i use onGloballyPositioned or onPlace and state the edge moves after i drag the node.
Copy code
Viewport {
    Node {
        Handler()
        Handler()
        Handler()
    }
    
    Node {
        Handler()
        Handler()
        Handler()
    }
    
    Edge {
        
    }

    Edge {

    }
}
g
One approach would be to implement your own layout, so you know the position and size of all the children. See
SubcomposeLayout
. If you measure the nodes first, you can then size Edge children but you'll still need to pass in the specific coordinate of where the lines should be drawn at the boundaries of those child composables. As an example of this approach, you can have a look at how the connector lines are drawn between pie slices and labels in this pie chart implementation: https://github.com/KoalaPlot/koalaplot-core/blob/main/src/commonMain/kotlin/io/github/koalaplot/core/pie/PieChart.kt