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({ url:'fldr/window.js', backgroundColor:'#fff', barColor:LAYOUT.barColor }); 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?
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.
Your Answer
Think you can help? Login to answer this question!