Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-4198] iOS: removeEventListener Removes All Events

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2011-10-27T15:43:34.000+0000
Affected Version/sRelease 1.7.0
Fix Version/sSprint 2011-24, Release 1.8.0
ComponentsiOS
Labelsn/a
ReporterDawson Toth
AssigneeBlain Hamon
Created2011-05-24T10:03:04.000+0000
Updated2011-10-27T15:43:34.000+0000

Description

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

Comments

  1. Blain Hamon 2011-06-13

    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?
  2. Dawson Toth 2011-06-14

    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.
  3. Don Thorp 2011-06-19

    temporarily turning of customer flag for a test.
  4. Don Thorp 2011-06-19

    re-enabling customer field.
  5. Blain Hamon 2011-06-20

    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.
  6. Blain Hamon 2011-06-21

    Pull was accepted
  7. Natalie Huynh 2011-08-25

    Tested with 1.8.0.v20110819142548 iPhone 4.3.4 iPad2 4.3.2 Motorola Xoom 3.2 Nexus One 2.2.2

JSON Source