Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-6436] Android: change window.js addEventListener and addWrappedListener to use this.view rather than window

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2012-01-04T15:36:47.000+0000
Affected Version/sRelease 1.8.0.1
Fix Version/sSprint 2011-48, Release 1.8.0.1
ComponentsAndroid
Labelsbranch-v8, module_window, qe-testadded
ReporterOpie Cyrus
AssigneePing Wang
Created2011-12-02T13:31:42.000+0000
Updated2012-04-17T12:12:40.000+0000

Description

In window.js, the addEventListener and addWrappedListener method should use this.view rather than this.window as this.window in the case of LW windows will not represent the actual view we are interested in getting events from. The implementation works but only due to bubbling.

Comments

  1. Opie Cyrus 2011-12-02

    Testing for this ticket should include re-verifying both timob-6096 and timob-6393 with the new change.
  2. Ping Wang 2011-12-02

    Use the code below to test removeEventListener. Longpress anywhere in the window (except the button and the labels), the bottom text should show "longpress triggered". Press the button and longpress in the window, the label with "longpress triggered" doesn't show up.
       var win = Ti.UI.createWindow(); 
       
       win.backgroundColor = '#13386c';
       win.name = "window";
       
       var button = Ti.UI.createButton({
       	title:'Remove longpress listener from window',
       	height:40,
       	width:400,
       	top:400
       });
       
       var l = Ti.UI.createLabel({
       	color:'white',
       	font:{fontSize:14,fontWeight:'bold',fontFamily:'Helvetica Neue'},
       	bottom:5,
       	textAlign:'center',
       	text:'longpress anywhere',
       	height:'auto',
       	width:'auto'
       });
       
       var l2 = Ti.UI.createLabel({
       	color:'white',
       	font:{fontSize:14,fontFamily:'Helvetica Neue'},
       	bottom:25,
       	textAlign:'center',
       	text:'',
       	height:'auto',
       	width:'auto'
       });
       
       win.add(l);
       win.add(l2);
       win.add(button);
       
       function clear(o)
       {
       	var t  = o.text;
       	setTimeout(function()
       	{
       		if (o.text == t)
       		{
       			o.text = "";
       		}
       	},1000);
       }
       
       function listener() {
       	l.text = "longpress triggered";
       	clear(l);
       }
       
       win.addEventListener('longpress', listener);
       
       button.addEventListener('click', function() {
       	win.removeEventListener('longpress', listener);
       });
       
       win.addEventListener('click',function(ev)
       {
       	l2.text = "window: You clicked on " +ev.source.name;
       	clear(l2);
       });
       
       win.open();
       
  3. Dustin Hyde 2011-12-05

    Bug fixed. Verified on: SDK: 1.8.0.1.v20111205011857 Runtimes: Android V8/Rhino Studio: 1.0.7.201112041107 OS: OS X Lion Devices Tested: Nexus One 2.2.2, Droid3 2.3.4, Slate 3.1, Emulator 4.0
  4. Dustin Hyde 2012-01-04

    Added label qe-testadded.

JSON Source