Problem
Removing an event listener from an object causes that object and all children objects to not receive any events (including events that were not removed from it).
Sample Code
var win = Ti.UI.createWindow({ backgroundColor: '#fff' });
var button = Ti.UI.createButton({
title: 'Remove A Listener',
top: 10, left: 10, right: 10, height: 50
});
function listenerToRemove() {}
win.addEventListener('junk', listenerToRemove);
button.addEventListener('click', function () {
alert('Removed!');
win.removeEventListener('junk', listenerToRemove);
});
win.add(button);
win.open();
How To Reproduce
Drop the above code in an app.js
When the app launches, a listener will be added for the "junk" event
Click the button, and "junk" will no longer be listened for
Try to click the button again. If nothing happens, this bug exists.
Tested On
BROKEN in iPhone Simulator 4.2 on Ti Mobile SDK 1.7.0.RC1
BROKEN in iPhone Simulator 4.2 on Ti Mobile SDK 1.6.2
WORKS on Android Samsung EPIC 4G 2.3 on Ti Mobile SDK 1.7.0.RC1
Associated Helpdesk Ticket
http://appc.me/c/APP-445715
This is actually due to the window treating the event removal as reason to turn off user interaction. If you replace 'junk' with 'click', this may still happen even after the codefix. Is this a new bug or a different bug?
I'm not sure what you mean. If calling "removeEventListener" is causing something to turn off its user interaction, that seems like the behavior we're seeing with this bug.
temporarily turning of customer flag for a test.
re-enabling customer field.
This is outside the scope of this bug, but may be of issue later on: Whither multi-touch? It's similarly effected, but there are some complexities in this.
Pull was accepted
Tested with 1.8.0.v20110819142548 iPhone 4.3.4 iPad2 4.3.2 Motorola Xoom 3.2 Nexus One 2.2.2