[TIMOB-19759] iOS: Parity: tab listeners
| GitHub Issue | n/a |
|---|---|
| Type | Improvement |
| Priority | Low |
| Status | Closed |
| Resolution | Fixed |
| Resolution Date | 2015-12-07T05:25:20.000+0000 |
| Affected Version/s | n/a |
| Fix Version/s | Release 5.2.0 |
| Components | iOS |
| Labels | qe-5.2.0, tab, tabGroup |
| Reporter | Chee Kiat Ng |
| Assignee | Angel Petkov |
| Created | 2015-10-22T02:00:26.000+0000 |
| Updated | 2016-02-15T13:50:48.000+0000 |
Description
On Android you listen for the events on the Tab object, but on iOS you listen for the events on the TabGroup.
On Android, Windows and iOS the TabGroup has a
focusevent with information on the previous and current active tab, even though it is [documented as Android and Windows only](http://docs.appcelerator.com/platform/latest/#!/api/Titanium.UI.TabGroup-event-focus). For iOS we've now addedselectedandunselectedevents to the TabGroup with TIMOB-18099, which really should have been added to the Tab, like [Android](http://docs.appcelerator.com/platform/latest/#!/api/Titanium.UI.Tab-event-selected) has. * TIMOB-18099 should be reverted. * The TabGroup'sfocusevent should be documented for iOS as well. * Theselectedandunselectedevents should be added to the Tab for both iOS and Windows.PR pending https://github.com/appcelerator/titanium_mobile/pull/7498.
var win1 = Ti.UI.createWindow({ backgroundColor : 'blue', title : 'Blue' }); win1.add(Ti.UI.createLabel({text: 'I am a blue window.'})); var win2 = Ti.UI.createWindow({ backgroundColor : 'red', title : 'Red' }); win2.add(Ti.UI.createLabel({text: 'I am a red window.'})); var tab1 = Ti.UI.createTab({ window : win1, title : 'Blue' }), tab2 = Ti.UI.createTab({ window : win2, title : 'Red' }), tabGroup = Ti.UI.createTabGroup({ tabs: [tab1, tab2] }); //Should display deprecated message. tabGroup.addEventListener("focus", function(e){ Ti.API.info("tabGroup is focused "); Ti.API.info(e); }); tabGroup.addEventListener("blur", function(e){ Ti.API.info("tabGroup is blured "); Ti.API.info(e); }); //Should display deprecated message. tab1.addEventListener("focus", function(e){ Ti.API.info("Tab1 is focused "); }); tab1.addEventListener("blur", function(e){ Ti.API.info("Tab is blured "); }); tab2.addEventListener("selected", function(e){ Ti.API.info("Tab2 is selected"); Ti.API.info(e); }); tab2.addEventListener("unselected", function(e){ Ti.API.info("Tab2 is unselected"); Ti.API.info(e.index); }); tabGroup.open();Shouldn't we first deprecate the tabgroup's selected and unselected events we've added in 5.1.0 and remove them in 6.0? Also, I think the PR is missing adding iOS as platform to the tabgroup's focus and blur events?
[~apetkov] Kindly address the comments.
PR updated. Deprecated the unselected/selected events. Also added platform tags to the focus/blur events on the docs.
PR merged.
Verified fixed,
focusevent now returns deprecated message, in favour of newselected&unselectedevents. New events working correctly. Tested on: iPhone 6s Plus Device (9.2) & iPhone 6 Plus Device (8.4) Mac OSX El Capitan 10.11 (15A284) Ti SDK: 5.2.0.v20160114021251 Appc NPM: 4.2.3-1 App CLI: 5.2.0-231 Xcode 7.2 Node v4.2.3 *Closing Ticket.*