Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-13816] Mobileweb: e.source returning incorrect object when clicking a button

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionWon't Fix
Resolution Date2017-06-26T18:42:53.000+0000
Affected Version/sRelease 3.1.0, Release 3.2.0
Fix Version/sn/a
ComponentsMobileWeb
Labelsn/a
ReporterTony Lukasavage
AssigneeChris Barber
Created2013-05-10T15:31:13.000+0000
Updated2018-04-04T23:20:31.000+0000

Description

problem

When adding a "click" event to a Ti.UI.Button in Mobileweb, the event object's "source" property is not the Ti.UI.Button that a developer would expect. Instead a Ti.UI.View seems to be returned that does not actually represent the button. My first thought was that it had something to do with event bubbling, but only one occurrence of the event is fired and it only returns this somewhat bogus object. Just to be sure I set e.cancelBubble to true and I still encounter the same issue. The use of e.source for identification is fairly common when multiple UI components will be referencing the same callback function. Android and iOS behave as expected, returning the Ti.UI.Button as the e.source.

test case

The issue surfaced in one of the Alloy test apps, but I've reduced it to a minimal, traditional Titanium test case.
var win = Ti.UI.createWindow({
	backgroundColor: '#fff'	
});
var button = Ti.UI.createButton({
	title: 'press me'	
});

button.addEventListener('click', function(e) {
	alert('source: ' + e.source.title + '\nobject: ' + e.source.toString());
});

win.add(button);
win.open();
Essentially, I would expect that the output of clicking the button would be:
source: 'press me'
object: [object TiUIButton]
where I could then make decisions in my callback based on the title property of the button. Instead, it returns this which is not in line with the other platforms:
source: undefined
object: [object TiUIView]
Also I am not relying solely on the text output. I've tested the returned object and it is not a Button that happens to be returning the wrong information.

expected

e.source in the above test case should return a reference to the Ti.UI.Button that was clicked.

Comments

  1. Lee Morris 2017-06-26

    Marking ticket as "Won't Fix" as MobileWeb has been deprecated.
  2. Eric Merriman 2018-04-04

    Closing as will not fix.

JSON Source