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?
2 Answers
-
Nevermind - that seems to work ok now. Not sure what was happening before
-
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:
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.