Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-19759] iOS: Parity: tab listeners

GitHub Issuen/a
TypeImprovement
PriorityLow
StatusClosed
ResolutionFixed
Resolution Date2015-12-07T05:25:20.000+0000
Affected Version/sn/a
Fix Version/sRelease 5.2.0
ComponentsiOS
Labelsqe-5.2.0, tab, tabGroup
ReporterChee Kiat Ng
AssigneeAngel Petkov
Created2015-10-22T02:00:26.000+0000
Updated2016-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.

Comments

  1. Fokke Zandbergen 2015-11-13

    On Android, Windows and iOS the TabGroup has a focus event 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 added selected and unselected events 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's focus event should be documented for iOS as well. * The selected and unselected events should be added to the Tab for both iOS and Windows.
  2. Angel Petkov 2015-11-25

    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();
       
  3. Fokke Zandbergen 2015-11-26

    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?
  4. Chee Kiat Ng 2015-11-27

    [~apetkov] Kindly address the comments.
  5. Angel Petkov 2015-11-30

    PR updated. Deprecated the unselected/selected events. Also added platform tags to the focus/blur events on the docs.
  6. Chee Kiat Ng 2015-12-07

    PR merged.
  7. Harry Bryant 2016-01-20

    Verified fixed, focus event now returns deprecated message, in favour of new selected & unselected events. 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.*

JSON Source