Alloy: Ti.UI.Window.titleControl and Ti.UI.Window.rightNavButton in view markup

You must Login before you can answer or comment on any questions.

Hey Guys,

I just started to take a deeper look into Alloy and I realy enjoy it! Great work!

I have a question regarding view markup. How can I add a Ti.UI.View to Ti.UI.Window.titleControl and how can I add a Ti.UI.Button to Ti.UI.rightNavButton?

Thanks in advance!

2 Answers

Accepted Answer

FYI, as of Alloy 1.0.0, you can do this directly in markup as with all other proxy properties:

<Alloy>
    <Window>
        <NavigationGroup>
            <Window id="firstWin">
                <RightNavButton>
                    <Button id="myRightNavButton" onClick="doSomething"/>
                </RightNavButton>
            </Window>
        </NavigationGroup>
    </Window>
</Alloy>

RIght now you'd have to do it in controller code, but we have plans for making this much easier in the future. The way it will likely be implemented would allow you to simply assign an ID to the target property. Something like this (again, this is not implemented yet):

<Window rightNavButton="$.rightButton">
    <Button id="rightButton"/>
</Window>
In the above sample, the button contained in the window would be used as its rightNavButton.

— answered 8 months ago by Tony Lukasavage
answer permalink
7 Comments
  • Hey Tony, thanks for your quick reply! Could you please give me a tip or an example how "to do it on controller code" as you said?

    — commented 8 months ago by René Bröcker

  • This is untested, but this is how you would add a rightNavButton to ta window, for example:

    index.xml
    <Alloy>
        <Window>
            <NavigationGroup>
                <Window id="firstWin"/>
            </NavigationGroup>
        </Window>
    </Alloy>

    index.js
    $.firstWin.rightNavButton = Ti.UI.createButton({
        // fill in the properties for your rightNavButton
    });

    — commented 8 months ago by Tony Lukasavage

  • you can create the button in the xml file and then assign it, it is cleaner and leaves all of the UI elements in XML.

    <Window id='firstWin'>
        <Button id="rightButton"/>
    </Window>
    in controller
    $.firstWin.rightNavButton = $.rightButton
    that is tested :-) I have done it in some apps

    — commented 8 months ago by Aaron Saunders

  • Show 4 more comments

Your Answer

Think you can help? Login to answer this question!