The compiler supports a special property called mxmlContent that defers the 
creation of the MXML tags assigned to that property until a bit later in the 
lifecycle in order to try to make sure other properties are set up before the 
children in the mxmlContent are.  All other mxml tags are created at 
constructor time.  mxmlContent is the [DefaultProperty] of Royale containers so 
instead having everyone type "mxmlContent" tags over and over again, you just 
skip having to type "mxmlContent".

So, one option is to define other properties to hold other sets of children.  
They will be instantiated at constructor time, but you can store them anywhere. 
 IMO, it is bad practice to store UI widgets in the model, but some components 
have both a data model and a presentation model that holds things that are 
about the view (DataGrid rowHeight for example) and not about the data itself.

Another option is to think of this component like a Navigator like ViewStack.  
Then you'd have two containers in the mxmlContent, one that holds the tabs or 
the tabbar itself and another that holds the "complex one with a dropdown".

Yet another option is to think of it sort of like Panel.  Panel has both a 
TitleBar and mxmlContent.  You can specify a completely different TitleBar for 
a Panel.

HTH,
-Alex

On 1/22/19, 1:12 AM, "Harbs" <[email protected]> wrote:

    We are working on a component which has two (very different) views 
depending on available space.
    
    I’d like to have some markup which would look like this:
    <foo:TabBar>
    <foo:Tab text=“Tab 1”/>
    <foo:Tab text=“Tab 2”/>
    <foo:Tab text=“Tab 3”/>
    <foo:Tab text=“Tab 4”/>
    </foo:TabBar>
    
    The internal structure would change from a relatively simple one to a 
complex one with a dropdown when there’s little space.
    
    I’d like to have a TabModel which would have an array of the tabs 
specified. I’d have a separate view which is responsible for actually adding 
the elements. My question is how to have the MXML children added to the model 
instead of the default behavior where they are added as elements.
    
    Thanks,
    Harbs

Reply via email to