1
votes

Stack with localToGlobal

I have this code (see id=search):

<s:NavigatorContent id="clients" width="100%" height="100%" >
    <s:layout>
        <s:VerticalLayout gap="0"
                          paddingBottom="0"
                          paddingLeft="0"
                          paddingRight="0"
                          paddingTop="0"/>
    </s:layout>

    <s:SkinnableContainer backgroundColor="0xF3F3F3" width="100%" height="40">
        <s:layout>
            <s:HorizontalLayout verticalAlign="middle"
                                paddingLeft="3"
                                paddingBottom="2"
                                paddingTop="2"
                                paddingRight="3"/>
        </s:layout>

        <s:Button id="addClientBtn"
                  label="{resourceManager.getString(
                      'myResources','workplace.addClientBtn')}"
                  icon="{Images.add}"
                  click="{addClient()}"
                  doubleClickEnabled="true"
                  doubleClick="{openHelp('NewClient')}"/>

        <s:Spacer width="100%" />

        <components:SearchClients id="search"/>
    </s:SkinnableContainer>
</s:NavigatorContent>

In creationComplete event ->

search.localToGlobal( new Point(search.x,search.y)) 

Output returns  
(x=0, y=32)

But visually I see that this output is wrong. Should be something like ~ (x=300, y=32)

Can someone help?

2

2 Answers

0
votes

You calculate point relative to search, so you need set zero point:

search.localToGlobal(new Point(0, 0));
0
votes

This is not quite correct:

search.localToGlobal(new Point(search.x,search.y));

search.x and search.y are co-ordinates relative to the NavigationContainer where search.localToGlocal expect to points relative to search ie x,y point local to search and convert them to global co-ordinates.

I think what you want is:
search.localToGlobal(new Point(0, 0));

You may want to check the creationPolicy of the ViewStack (by default it's auto) and if this view is the first view at the point of doing this calculation. By default only one view (the first) will exist in a view stack when the application creationComplete method is called.