开发者

Titanium titlebar button to toggle about screen

开发者 https://www.devze.com 2023-01-23 11:57 出处:网络
Trying to get a button working in the titlebar is becoming a little difficult. At present the button opens when clicked (calls a window with a webview), and closes when an html button is clicked. But

Trying to get a button working in the titlebar is becoming a little difficult. At present the button opens when clicked (calls a window with a webview), and closes when an html button is clicked. But only once. The issue is that after the window is closed, the titlebar button seemingly wont reopen the window...

This is probably a simple error, but one i'm having difficulty finding an answer to.

My app.js:

var infoBtn = Titanium.UI.createButton({
    title:'Info'
});

// ABOUT
var win0 = Titanium.UI.createWindow();

var webview0 = Titanium.UI.createWebView({url: 'about.html'});

infoBtn.addEventListener('click', function() { win0.open(); });
Ti.App.addEventListener('closeAbout', function() { win0.close(); });

win0.add(webvie开发者_如何转开发w0);
win0.hideNavBar();

My about.html:

<head>
<script type="text/javascript" charset="utf-8">
function closeAboutBtn() {
    Ti.App.fireEvent('closeAbout');
}
</script>
</head>

<body>
<a href="#" class="btn" onClick="closeAboutBtn(); return false;">Return to App</a>
</body>

Would anyone have any ideas on how to fix so the about button shows the content when pressed every time?


First quick response would to be just "hide" the window instead of closing it.

verified:

The only way I was able to consistently get he window to hide and show is as follows

// listener assigned to info button
infoBtn.addEventListener('click', function() { 
    Ti.API.log('info button clicked, show window');
    win2.open(); 
    win2.show(); 
});

// Listener assigned to close in about window
Ti.App.addEventListener('closeAbout', function(data) { 
    Ti.API.log('info button clicked, close window');
    win2.close(); 
    win2.hide();
});
0

精彩评论

暂无评论...
验证码 换一张
取 消