Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-6393] Android: Lightweight Window, Source of Events is undefined

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2012-01-18T16:17:46.000+0000
Affected Version/sn/a
Fix Version/sRelease 1.8.0.1, Sprint 2012-02, Release 2.0.0, Release 1.8.1
ComponentsAndroid
Labelsbranch-v8, module_window, parity, qe-testadded
ReporterPing Wang
AssigneePing Wang
Created2011-11-30T15:05:14.000+0000
Updated2012-03-04T22:12:16.000+0000

Description

Run the code below. Click the anywhere in the window except the bottom label, the bottom label shows "window: You clicked on undefined". Expected behavior: The bottom label shows "window: You clicked on window".
var win = Ti.UI.createWindow(); 

win.backgroundColor = '#13386c';
win.name = "window";

var l2 = Ti.UI.createLabel({
	color:'white',
	font:{fontSize:14,fontWeight:'bold',fontFamily:'Helvetica Neue'},
	bottom:5,
	textAlign:'center',
	text:'click anywhere',
	height:'auto',
	width:'auto'
});


win.add(l2);

function clear(o)
{
	var t  = o.text;
	setTimeout(function()
	{
		if (o.text == t)
		{
			o.text = "";
		}
	},1000);
}

win.addEventListener('click',function(ev)
{
	l2.text = "window: You clicked on " +ev.source.name;
	clear(l2);
});

win.open();

Comments

  1. Natalie Huynh 2011-12-21

    Tested with 1.8.0.1.v20111220190134 on LG Slate (3.1) v8/rhino
  2. Natalie Huynh 2012-01-04

    Still encountering the issue. If you click in the label area when the label is not invoked you will see "You clicked on a window", but if you click the label area when it is invoked, you get "You click on undefined" Tested with 1.8.0.1
  3. Ping Wang 2012-01-17

    When we click the label area, the source of events is the label. Since we don't specify the name of the the label in the code, it will show "You click on undefined". Therefore, it's an expected behavior. In order to avoid such confusion, write another test sample below.
       var win = Ti.UI.createWindow(); 
       
       win.backgroundColor = '#13386c';
       win.name = "window";
       
       win.addEventListener('click',function(ev)
       {
       	Ti.API.info("window: You clicked on " +ev.source.name);
       });
       
       win.open();
       
    Click anywhere in the window and check the log. The expected behavior: "window: You clicked on window" shows in the log.
  4. Natalie Huynh 2012-01-18

    Tested with 1.9.0.v20120118110134

JSON Source