Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@evanmcd
Created March 10, 2011 16:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save evanmcd/864415 to your computer and use it in GitHub Desktop.
Save evanmcd/864415 to your computer and use it in GitHub Desktop.
A window opened from app.js - demonstrating lack of functioning zIndex in Titanium windows
var win = Titanium.UI.currentWindow;
var menuOpen = false;
var lbl = Titanium.UI.createLabel({
color:'#FFF',
text:'Base',
right:0
});
win.add(lbl);
var contentWin1 = Ti.UI.createWindow({
backgroundColor:'blue',
url:'contentWin1.js',
width:1024,
height:768,
top:0,
left:50,
zIndex:0
});
var contentWin2 = Ti.UI.createWindow({
backgroundColor:'green',
url:'contentWin2.js',
width:1024,
height:768,
top:0,
left:100,
zIndex:1
});
var menu = Ti.UI.createWindow({
backgroundColor:'#333',
url:'menu.js',
width:512,
height:768,
top:0,
left:0,
zIndex:2
});
var btn = Ti.UI.createButton({
title:'Close/Open',
width:100,
height:50,
top:20,
left:20
});
win.addEventListener('open',function(e){
Ti.API.info('Base opened from base.js');
contentWin1.open();
});
contentWin1.addEventListener('open', function(){
Ti.API.info('win1 opened');
contentWin2.open();
});
contentWin2.addEventListener('open', function(){
Ti.API.info('win2 opened');
if(!menuOpen) {
menu.open();
menuOpen = true;
} else {
contentWin1.animate({zIndex:10},function(){
Ti.API.info('win1 z: ' + contentWin1.zIndex);
});
contentWin2.animate({zIndex:20,top:10},function(){
Ti.API.info('win2 z: ' + contentWin2.zIndex);
});
menu.animate({zIndex:30,top:10},function(){
Ti.API.info('menu z: ' + menu.zIndex);
});
}
});
menu.addEventListener('open', function(){
Ti.API.info('menu opened');
menu.add(btn);
});
btn.addEventListener('click',function(){
contentWin2.close();
contentWin2.open();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment