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();
Is there a specific reason why the "singletap", and not the "click" event, must be used? This code could be replaced with the following:
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 betweensingletap
andclick
. Internally, iOS may not give us enough information on thesingletap
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 getsingletap
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.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.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.
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).
As per Steven, cannot address. closing.