sparkle
sparkle

Reputation: 7390

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

Upvotes: 1

Views: 1046

Answers (1)

Dawson Toth
Dawson Toth

Reputation: 5670

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.

Upvotes: 3

Related Questions