Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-5192] iOS: Windows in NavigationBar are missing some events

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2012-08-01T01:32:05.000+0000
Affected Version/sRelease 1.8.0
Fix Version/sRelease 2.0.1
ComponentsiOS
Labelsmodule_window, qe-testadded
ReporterKarol Pomaski
AssigneeNeeraj Gupta
Created2011-09-01T14:52:27.000+0000
Updated2013-12-02T09:14:53.000+0000

Description

Problem

"focus" event is not fired while it should be. The "open" event is fired twice while entering to the application.

Reproducible Steps

1. Run the attached code. This application is presenting the four ("open","close","blur","focus") events. While the event for win1, win2, navGroup are fired in the log terminal you would see the information. 2. Look that after running the application we get these logs: [INFO] Win1 received "open" event. [INFO] Win1 received "open" event. It means that "open" event was fired twice (why?) and there is no "focus" event for win1. 3. Click at the "Open Win2" button. 4. Look at the logs: [INFO] clicked b1 [INFO] Win1 received "blur" event. [INFO] Win2 received "open" event. We don't receive the "focus" event for Win2, however this window gained the focus. 5. Click at the button "Close Win2" 6. Look at the logs: [INFO] Win2 received "blur" event. [INFO] Win1 received "focus" event. [INFO] Win2 received "close" event. [INFO] Win1 received "open" event. That is correct.

Sample Code

var mainWin = Ti.UI.createWindow({backgroundColor:'yellow'});
var navGroup = Ti.UI.iPhone.createNavigationGroup();

var win1 = Titanium.UI.createWindow({  
    title:'Win1',
    backgroundColor:'white'
});

var win2 = Titanium.UI.createWindow({
	title:'Win2',
	backgroundColor:'40A040'
});

var b1 = Titanium.UI.createButton({
	title:'Open Win2',
	width:150, height:50
});
win1.add(b1);

b1.addEventListener('click', function(e){
	Ti.API.info('clicked b1');
	navGroup.open(win2);
});

win1.addEventListener("close",function(e){
	alert("close");
});

var b2 = Titanium.UI.createButton({
	title:'Close Win2',
	width:150, height:50
});
win2.add(b2);

b2.addEventListener('click', function(e){
	Ti.API.info('clicked b2');
	navGroup.close(win2);
});

function addEventListener(obj, eventName) {
	obj.addEventListener(eventName, function (e) {
		Ti.API.info(obj.title + ' received "' + eventName + '" event. Source: ' + e.source);
	});
}

var eventNames = [ 'open', 'close', 'blur', 'focus' ];
var objects = [ win1, win2, navGroup ];

for(var i=0; i<eventNames.length; i++) {
	for(var j=0; j<objects.length; j++) {
		addEventListener(objects[j], eventNames[i]);
	}
}

navGroup.window = win1;
mainWin.add(navGroup);
mainWin.open();

Associated HD ticket

http://appc.me/a/APP-178191

Attachments

FileDateSize
navgroup.zip2011-09-01T14:52:28.000+00001580540

Comments

  1. Paul Mietz Egli 2011-11-01

    Point #2 is especially important to me because I am having to write event listeners for both the open and focus events which do the same thing (asynchronously load table data).
  2. Nikhil Sharma 2012-05-16

    It has been fixed in Ti SDK 2.0.1.GA2. Close it
  3. Satyam Sekhri 2012-07-16

    The Open event is fired only once when the win1 opens. Also the focus event is fired for Win1 and Win2. Verified On: Titanium Studio: 2.1.1.201207121732 Titanium SDK: 2.1.1.v20120712160111 Device: iPhone 4S (v5.1)
  4. Neha Chhabra 2012-08-01

    Reopening to update labels

JSON Source