[TIMOB-1423] iOS: Window focus and blur events fire twice
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | High |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2011-11-05T15:25:17.000+0000 |
Affected Version/s | Release 1.6.0 |
Fix Version/s | Sprint 2011-31, Release 1.8.0 |
Components | iOS |
Labels | n/a |
Reporter | Jon Clarke |
Assignee | Blain Hamon |
Created | 2011-04-15T02:51:57.000+0000 |
Updated | 2011-11-05T15:25:17.000+0000 |
Description
Create a tab bar with a couple of tab buttons.
One of the tab buttons opens a window. This window opens another window with a back button (in example below from a table view). Clicking on the back button, the original window fires a focus event which is fine. However, when the second window is open, if you click the tab button again (NOT the back button) to go back to the original window, the original window's focus event fires, then the blur event, then focus. Only the focus event should fire once!
Code (test2.js doesn't really do anything but is not important
here)
// get current window
var win = Titanium.UI.currentWindow;
var data = [{title:'row 1'},{title:'row 2'},{title:'row 3'},{ title:'row 4'}];
var table = Ti.UI.createTableView({data:data, editable:false});
table.addEventListener('click', function(e)
{
var newwin = Titanium.UI.createWindow({
title:'test 2',
backButtonTitle : 'Back',
url:'../scripts/test2.js'
});
// open the window in the current tab
Titanium.UI.currentWindow.tabGroup.activeTab.open(newwin,{animated:true});
});
win.addEventListener("focus",function(e) { Ti.API.info('test focus');
table.data = data;
});
win.addEventListener("blur",function(e) { Ti.API.info('test blur');
table.data = [];
});
win.add(table);
when returning from newwin, is there a way to fire a refresh event on win? I have been trying to do this by calling the "focus" event on win, but it only fires the first time win opens. Not when returning from newwin.
any ideas?
Preliminary testing indicates this is still valid.
A http://developer.appcelerator.com/helpdesk/view/73281#c347631">Helpdesk customer is having the same problem. I'm just confirming that the bug still exist.
There is also a related problem: tabGroup focus fires three times when opened. Example code:
Console:
iPhone Simulator 4.2
Ti SDK 1.6 RC1
Associated Helpdesk Ticket
http://support.appcelerator.com/tickets/APP-953212Additional info
Tested with TiSDK 1.7.x and monitored the FOCUS event that is being fired 4 times.Tested on
iPhone Simulator 4.2Console output
{noformat} [INFO] Focus fired [INFO] Focus fired [INFO] Focus fired [INFO] Focus fired {noformat}Tested On: Mac OSX Lion TiMob: 1.8.0v20110819142548 TiStud: 1.0.4.201108101535 Devices: iPhone4 version 4.2.10 iPad2 version 4.3.5 iPod 3
Standardizing summary and labels.