I'm trying to make my application minimize to the tray on Windows. I am using the following code which works, but I can only restore from the tray after the first time the application is minimized. The second time I minimize and try to restore from the tray, nothing happens when clicking the tray icon. I'm sure I've done something stupid, but can not find what it is. Could someone help me out?
function initTray() { var window = Titanium.UI.getCurrentWindow(); Titanium.UI.getCurrentWindow().addEventListener(Titanium.MINIMIZED, function(event) { window.hide(); tray = Titanium.UI.addTray("app://logo.png", function(evt) { if (evt.getType() == 'clicked') { Titanium.UI.clearTray(); window.show(); window.unminimize(); } }); }); }
2 Answers
This worked for me...
var window = Titanium.UI.getCurrentWindow(); Titanium.UI.getCurrentWindow().addEventListener(Titanium.MINIMIZED, function(event) { window.hide(); }); var tray = Titanium.UI.addTray("app://images/icon16.png", function(evt){ if (evt.getType() == 'clicked') { if (!currentWindow.isVisible()){ window.show(); window.unminimize(); } } });
last two codes worked but not functioning very well. because variable window. use below code var current_window = Titanium.UI.getCurrentWindow(); Titanium.UI.getCurrentWindow().addEventListener(Titanium.MINIMIZED, function(event) { current_window.hide(); });
tray = Titanium.UI.addTray("app://default_app_logo.png", function(evt) { if (evt.getType() == 'clicked') { if (!current_window.isVisible()) { current_window.show(); } } });
Your Answer
Think you can help? Login to answer this question!