Titanium.App.addEventListener not fired, never

app.js

var win1 = Titanium.UI.createWindow({
    title:'Tab 1',
    backgroundColor: 'black',
    layout: 'vertical',

});

win1.open();

Titanium.App.addEventListener('click', function(e) {
    console.log('clicked');
});

If I tap/click on the screen, the click event doesn't fire! Do you know why? All my code is that above on app.js

EDIT

  • If I would listen for a "swipe" event, how I would to do?

  • Why I don't see errors or warning in my debug console for this?

Answers


The "click" event is fired on the object that is clicked, namely, win1. So is "swipe". Please read the documentation to learn what events are available.

var win1 = Ti.UI.createWindow({
    title:'Tab 1',
    backgroundColor: 'black',
    layout: 'vertical'
});
win1.addEventListener('click', function(e) {
    Ti.API.info('clicked');
});
win1.addEventListener('swipe', function(e) {
    Ti.API.info('swiped');
});
win1.open();

Your code is valid, so no errors or warnings are displayed. But it does not do what you expect. Please read the documentation on the standard events that fire on Titanium.App, and on the custom events that you can fire on Titanium.App. Also read the documentation on Titanium.UI.View to understand what standard events are fired.


Need Your Help

Twitter Bootstrap : a language div breaks the menu

css drop-down-menu twitter-bootstrap menu alignment

I'm having some difficuilties with Twitter Bootstrap menu + adding a language dropdown menu.

Compass not displayed in iphone

iphone ipad

I have created one application in which i want to display compass.but my application is showing me blank page..I have added CoreLocation framework also..Please help me to display compass.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.