Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-6767] iOS: Disappearing events in tabbedbar nested in Views

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionWon't Fix
Resolution Date2012-03-27T13:48:49.000+0000
Affected Version/sRelease 1.7.5, Release 1.8.0.1
Fix Version/sn/a
ComponentsiOS
Labelsn/a
ReporterMauro Parra-Miranda
AssigneeStephen Tramer
Created2011-12-19T15:40:39.000+0000
Updated2012-03-27T13:48:49.000+0000

Description

PROBLEM DESCRIPTION

If you have a tabbedbar inside a view, the view won't get the events, like singletap.

STEPS TO REPRODUCE

1. Create a new mobile project 2. Paste the code below into app.js 3. Singletap on the buttons of the tabbedbar.

ACTUAL RESULTS

The singletap event is not fired.

EXPECTED RESULTS

Singletap event should be fired.

CODE

var win = Ti.UI.createWindow();
var view = Ti.UI.createView({
	touchEnabled:   true,
}); 
var bb1 = Titanium.UI.createTabbedBar({ 
	labels:['One', 'Two', 'Three'], 
	backgroundColor:'#336699', 
	top:50, 
	style:Titanium.UI.iPhone.SystemButtonStyle.BAR, 
	height:25, 
	width:200 }); 
	
view.add(bb1);
view.addEventListener('singletap',function(){
	Ti.API.info('Event singletap was fired!');
});
win.add(view);
win.open();

Comments

  1. Stephen Tramer 2011-12-21

    Is there a specific reason why the "singletap", and not the "click" event, must be used? This code could be replaced with the following:
       var win = Ti.UI.createWindow();
       var view = Ti.UI.createView({
       	touchEnabled:   true,
       }); 
       var bb1 = Titanium.UI.createTabbedBar({ 
       	labels:['One', 'Two', 'Three'], 
       	backgroundColor:'#336699', 
       	top:50, 
       	style:Titanium.UI.iPhone.SystemButtonStyle.BAR, 
       	height:25, 
       	width:200 }); 
       	
       view.add(bb1);
       
       function tapListener(event) {
         // ... event processing here, where you can:
         // 1. Switch on the source
         // 2. Switch on the event type
       }
       
       view.addEventListener('singletap',tapListener);
       bb1.addEventListener('click',tapListener);
       
       win.add(view);
       win.open();
       
    Or even simply listen for the click event on the view, which will pick up control changes on the tab bar (and is triggered as soon as the control changes value). In practice there tends to be little difference between singletap and click. Internally, iOS may not give us enough information on the singletap event to be able to reliably report the currently selected button in the control (in particular, singletap may be fired before the value is changed). We may not even be able to get singletap from the underlying control due to its native behavior. This bug indicates that our documentation needs to be updated to indicate where specific views may not support specific events.
  2. Stephen Tramer 2011-12-21

    Note that this comment applies only if the information from the click event (the currently selected button index) is required. Certain events may not be bubbling up as expected, which is a genuine bug.
  3. Stephen Tramer 2011-12-21

    Won't fix; checked and saw that the events required for processing 'singletap' don't even bubble up from the underlying control. Going to create a doc bug for improving documentation of views which do (and do not) handle specific events, and among those, which include additional information as part of the event.
  4. Stephen Tramer 2011-12-21

    Filed bug TIMOB-6825 for improving our documentation regarding event listeners. Unfortunately, generating parity information for event handling on iOS is not particularly easy outside of an app we can run to pump events through specific elements (probably the same for Android).
  5. Thomas Huelbert 2012-01-23

    As per Steven, cannot address. closing.

JSON Source