Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-23615] Windows: Problem adding eventlistener twice to Ti.UI.ImageView

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2016-07-06T02:34:22.000+0000
Affected Version/sRelease 5.4.0
Fix Version/sRelease 5.4.0
ComponentsWindows
Labelsn/a
ReporterJonas Bjurhult
AssigneeGary Mathews
Created2016-06-17T08:45:27.000+0000
Updated2016-07-06T15:52:49.000+0000

Description

1. Add eventListener to ImageView 2. Click ImageView 3. Remove eventListener 4. Add same eventListener again. 5. Click ImageView 6. Notice that the last click event will not be fired index.xml
<Alloy>
	<Window class="container" id="win">
		<Label id="label" onClick="doClick">Hello, World</Label>
	</Window>
</Alloy>
index.js
var imgview = Ti.UI.createImageView({height:100, width:100, image:'images/nav_backicon.png', top:10});
$.win.add(imgview);

imgview.addEventListener('click', clickListener);
Ti.API.info("added listener 1");

function clickListener(e) {
	alert("clicked");
	imgview.removeEventListener('click', clickListener);
	
	setTimeout(function () {
		imgview.addEventListener('click', clickListener);
		Ti.API.info("added listener 2");
	}, 2000);
}
$.win.open();

Attachments

FileDateSize
nav_backicon.png2016-06-17T08:45:18.000+0000353

Comments

  1. Ewan Harris 2016-07-05

    I can reproduce the behaviour described on: Windows 10 Pro Ti SDK: 5.3.0.GA, 5.4.0.v20160704082523 Appc NPM: 4.2.7-2 Appc CLI: 5.4.0-26 Appc Studio: 4.7.0.201606220541
       var win = Titanium.UI.createWindow();
       
       var imgview = Ti.UI.createImageView({
       	image: 'Logo.png'	
       });
       
       imgview.addEventListener('click', clickListener);
       Ti.API.info("added listener 1");
        
       function clickListener(e) {
       	alert("clicked");
       	imgview.removeEventListener('click', clickListener);
       	setTimeout(function () {
       		imgview.addEventListener('click', clickListener);
       		Ti.API.info("added listener 2");
       	}, 2000);
       }
       
       win.add(imgview);
       win.open();
       
       
  2. Kota Iguchi 2016-07-06

    https://github.com/appcelerator/titanium_mobile_windows/pull/768 https://github.com/appcelerator/titanium_mobile_windows/pull/769
  3. Kota Iguchi 2016-07-06

    Pushing this to 5.4.0 because it's critical.
  4. Ewan Harris 2016-07-06

    Verified using: Windows 10 Pro Ti SDK: 5.4.0.v20160705213725 Appc NPM: 4.2.7-2 Appc CLI: 5.4.0-26 Appc Studio: 4.7.0.201606220541 Lumia 930: 10.0 Lumia 520 : 8.1 The code sample attached now works as expected. Closing ticket

JSON Source