Reputation: 16214
I'd like to be able to show an error message (or maybe even a success message!) to the user. However, this would be for an asynchronous event - so it is presumably possible for the user to have jumped to another page in-between the sending for the event and the response.
Given that that is the case, and given that i use a tabgroup as the "base" in the initial app.xml, how am i meant to access the current window? Ti.UI.getCurrentWindow() doesn't do anything on my system - no error, no nothing.
I'm using the Titanium 3 api.
Upvotes: 1
Views: 8095
Reputation: 7904
currentTab only works if your app uses tabs.
currentWindow and getCurrentWindow() only work if the window was opened using the url property of the Ti.UI.createWindow method.
If you're in any other situation, the current window is just not available, it seems.
Upvotes: 0
Reputation: 446
Yes you can use Ti.UI.currentTab.window(). and since this is function so use "()", otherwise it will not give correct output
Upvotes: 2
Reputation: 581
Ti.UI.currentWindow only works if there is a window already open. The error you have is coming from the fact that when you create the MasterView, you have not yet opened up the window.
Look inside ApplicationWindow.js, you will see that you create the masterview before even opening the window.
If you want to set navbar items, either add them in the ApplicationWindow, app.js, or pass the window to the MasterView.
Upvotes: 1
Reputation: 11
to get current window use Ti.UI.getCurrentWindow and not Ti.UI.getCurrentWindow()
Upvotes: 1
Reputation: 6095
Since your using a tab group you can use Titanium.UI.currentTab
. Then you can get the window of the tab like this:
var theWindow = Titanium.UI.currentTab.window;
Specific doc reference (just in case).
Also, you can always use a Titanium.UI.AlertDialog
, that will show up no matter what window your on, if it meets your requirements.
Upvotes: 3