Titanium.UI.currentTab/currentWindow is null ?
Closed this issue · 4 comments
Hi,
I use this code, like in kitchen Kit :
//-- controller/index.js
var tabGroup = Titanium.UI.createTabGroup();
//Create tab for root
$.contactsListWin.getRoot().navBarHidden='true';
$.contactsListWin.getRoot().tabBarHidden='true';
var MenuTab = Titanium.UI.createTab({
title:'',
window:$.contactsListWin.getRoot(),
});
tabGroup.addTab(MenuTab);
//tabGroup.setActiveTab(1);
// open tab group with a transition animation
tabGroup.open({
transition: Titanium.UI.iPhone && Titanium.UI.iPhone.AnimationStyle.FLIP_FROM_LEFT
});
and in my controller/showcontact.js
$.t.addEventListener('click', function(e)
{
console.log('click'); //return click
console.log(Titanium.UI.currentTab); //return NULL
console.log(Titanium.UI.currentWindow); //return NULL
});
my contactsListWin.xml :
<Window class='container' id='contactsListWin'>
<Label id="t">Middle</Label>
</Window>
Titanium.UI.currentTab & Titanium.UI.currentWindow return null, and i don't understand why...
This is mentioned in #29 as well. We are putting this issue into our issue list and will address in the near future.
Ok, thank for kind reply.
you have a temporary solution, maybe with a eventHandler (focus?) ?
I don't have a temporary fix for you quite yet, but one thing to note is that you can construct a tabgroup and tabs in the markup, you don't need to do it in code.
<TabGroup>
<Tab>
<Window>
<!-- the rest of your views -->
</Window>
</Tab>
</TabGroup>
Take a look here for a full, basic sample: https://github.com/appcelerator/alloy/tree/master/test/apps/tabgroup
Ti.UI.currentTab
and Ti.UI.currentWindow
are always null in single context applications. There is an associated ticket that briefly mentions this:
https://jira.appcelerator.org/browse/TIMOB-2797
also, to see in exhaustive detail exactly how you can manage tabs in a single context application, check out this blog post, which not only covers the topic, but has a full screencast detailing the techniques: