Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Open new Window from rightNavButton

I'm trying to create a new window when a user clicks the rightNavButton, although nothing seems to be happening. Perhaps the rightNavButton was not meant for this. My code is:

var mapBtn = Titanium.UI.createButton({title:'Map'});
Titanium.UI.currentWindow.rightNavButton = mapBtn;

mapBtn.addEventListener('click', function(e){
    var win = Titanium.UI.createWindow({
        url:'map.js',
        title:'MAP!',
        backgroundColor:'transparent',
        barColor:'#fff',
    });
    Titanium.UI.currentTab.open(win,{animated:true});
})

Anybody have any clues?

— asked April 2nd 2010 by Marshall Jones
  • iphone
  • navbar
  • rightnavbutton
0 Comments

2 Answers

  • Nevermind - that seems to work ok now. Not sure what was happening before

    — answered April 2nd 2010 by Marshall Jones
    permalink
    0 Comments
  • Yes, this is what I got to work and that I'm sharing on threads:

    Add Button to Tab Group Toolbar/Navbar

    The code:

    var btnEdit = Ti.UI.createButton({
        systemButton: Ti.UI.iPhone.SystemButton.EDIT
    });
    btnEdit.addEventListener('click',function(e){
        // button was clicked
    });
    tabWin.rightNavButton = btnEdit;
    

    You can also add a left button by doing:

    tabWin.leftNavButton = btnEdit;
    

    Reading these two questions: one and two helped me figure this out.

    The buttons will then display like:

    http://i.imgur.com/EfrO4.png

    Note that this works for iPhones, not just iPads (haven't tested on Android). All the button options are listed here. Also, note that you can do similar things with the icons on the tab bar using these button styles.

    — answered April 15th 2011 by Joe iEntry
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.