Project: titanium
Issue TIMOB-8346: iOS: "open" event fires multiple times at startup, plus whenever focused when using NavigationGroup
h2.Problem The "open" event of a window fires 3 times when first opened, then whenever the window re-receives focus (when navigating back to it using a NavigationGroup), the "open" event fires again. h2.Expected Result The "open" event should only fire once...when it is first opened, period. And it should not fire when the window re-receives focus. h2.Steps to Reproduce # drop the following app.js code into a new project # build with SDK 1.8.1 # run in the iPhone simulator. You will see: {code} [INFO] One moment, building ... [INFO] Titanium SDK version: 1.8.1 (01/27/12 17:31 a24502a) [INFO] iPhone Device family: iphone [INFO] iPhone SDK version: 5.0 [INFO] iPhone simulated device: iphone [INFO] Launching application in Simulator [INFO] Launched application in Simulator (3.78 seconds) [INFO] Found 5.0 patch installed [INFO] Application started [INFO] NavGroupFocusTest/1.0 (1.8.1.a24502a) [INFO] rootWin OPEN fired [INFO] rootWin OPEN fired [INFO] rootWin OPEN fired {code} # Say to yourself: "Why did OPEN fire 3 times?!?!?!?!?!" # click the "open new window" button and watch the console log. You will see: {code} [INFO] 2nd wind {code} # click the "back" button and watch the console log. You will see: {code} [INFO] rootWin FOCUSED [INFO] rootWin OPEN fired {code} # Say to yourself: "Why did OPEN fire again?!?!?!?!?!" Repeat steps 5, 6, and 7 and continue to get the same result until you're bored with this game. h2.Testcase {code:title=app.js} var rootWin = Ti.UI.createWindow(); rootWin.addEventListener('focus', function() { Ti.API.info("rootWin FOCUSED"); }); rootWin.addEventListener('open', function() { Ti.API.info("rootWin OPEN fired"); }); var btnOpenWin = Ti.UI.createButton({ title : "open new window", width : 200, height : 35 }); btnOpenWin.addEventListener('click', function() { var win2 = Ti.UI.createWindow(); ng.open(win2, {animated:true}); Ti.API.info("2nd wind"); }); rootWin.add(btnOpenWin); ng = Ti.UI.iPhone.createNavigationGroup({window:rootWin}); var NavBase = Ti.UI.createWindow(); NavBase.add(ng); NavBase.open(); // this opens the "root" window, automatically {code} In a larger project, sometimes when you go "back" to the main window, no events fire at all (no focus, no open). I would expect the focus event to fire each time. Just something to keep in mind while you're looking into the code, as I haven't been successful in reproducing this in a small testcase.
Story points: 1