Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Determining which window is focused on resume

I'm trying to find out which one of my windows is focused upon resume of the app.

I have some code like this

Titanium.App.addEventListener('resume', function(e)
     // do something
    Titanium.addEventListener(Titanium.FOCUSED, function(event) { 
      Titanium.currentlyFocusedWindow = event.target; /// from an old post


I've also tried

    var win1 = Titanium.UI.createWindow({
    win1.addEventListener('focus', function(e) {
      Ti.API.info("IN THE FOCUS EVENT");

    win1.addEventListener('open', function(e) {
      Ti.API.info("IN THE OPEN EVENT");

    win1.addEventListener('resume', function(e) {
      Ti.API.info("IN THE RESUME EVENT");


It seems like the resume function only works on the application module, not on a window object.

The window focus and open events are not fired upon resume of the app.

So how would i be able to determine which window has focus upon resume of the app?

— asked August 30th 2010 by Sean McCullough
  • iphone
  • mobile
1 Comment
  • Did you ever come up with a solution for this?


    — commented December 5th 2011 by Derek Tumulak

1 Answer

  • We set this ourselves in a Property variable when a window gains focus. Then on resume, we can read the variable knowing what the last window opened was before the app was put into the background/asleep.

    For one of our apps, we created an appstate system that allows us to reopen sub windows. It is far from perfect, but for this particular situation it works ok.

    — answered December 14th 2011 by Stephen Feather
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.