[AC-2738] addEventListener on supperposed elements fired twice on iOS, and once on andrdoid
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | n/a |
Status | Closed |
Resolution | Needs more info |
Resolution Date | 2011-12-19T16:24:41.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | Titanium SDK & CLI |
Labels | 1.8.0, eventlistener, ios |
Reporter | edouard omont |
Assignee | Paul Dowsett |
Created | 2011-11-10T08:26:05.000+0000 |
Updated | 2016-03-08T07:47:38.000+0000 |
Description
In the sample code below, there is a view under a label. An addEventListener has been added to the view. The view and the label are different sized.
The behaviour is different between Android and iOS: The log message is displayed twice on iOS log for one click on the view while it is only displayed once on android.
var element=Titanium.UI.createView({
top:20,
height:150,
left:0,
width:200,
backgroundColor:'blue',
//backgroundImage:Titanium.Filesystem.resourcesDirectory+imageFond,
});
var lblTxt1=Titanium.UI.createLabel({
text:'mon label',
color:'#FFF',
font : {
fontSize : 22,
fontFamily : 'Helvetica Neue',
},
top:5,
height:75,
left:15,
width:100,
backgroundColor:'red',
});
element.add(lblTxt1);
element.addEventListener('click', function(e){
Titanium.API.info('addEventListener click sur element:'+e)
});
win.add(element);
This behaviour is unpleasant because all the code in the eventListener is executed twice....
I have the same problem but on Android. I tried it with 1.8.0.1 RC, nighty build 1.8.0.1 and 1.9.0. An view inside a row. And one click fires it 3 times. Strange. In the example below the click event handler (topStoryThumb.addEventListener('click'...) is executed 3 times. Am I missing something?
add the event to the table and check
if course, set to topStoryThumb something like
I have used a kind of a global variable (Titanium.App.top_story_news_opening). I ask for it in the click event function. If it's undefined or == false I open the window. Inside the window I set Titanium.App.top_story_news_opening = false, when every view is built and visible. Seems to work too ;) Because the problem is that the click event doesn't get fired from the table.
Thank you for raising this ticket. If you are able to provide all the information described in the [JIRA Ticket Checklist](http://wiki.appcelerator.org/display/guides/How+to+Submit+a+Bug+Report#HowtoSubmitaBugReport-JIRATicketChecklist) guidelines, *in the correct fields and using the right format*, I will be able to escalate it to the core team. Please click *edit* to amend the body of the ticket, rather than adding a comment. Also, your test case needs to run without modification when pasted into a blank app.js. I will mark this resolved for now. Please reopen when the ticket is complete. Thanks in advance.
Closing due to inactivity. If this issue still exists, please raise a new ticket, including all the information in the [JIRA Ticket Checklist](https://wiki.appcelerator.org/display/guides/How+to+Submit+a+Bug+Report#HowtoSubmitaBugReport-JIRATicketChecklist) to ensure that we can escalate it quickly. Read [How to Submit a Bug Report](https://wiki.appcelerator.org/display/guides/How+to+Submit+a+Bug+Report) if you have not read it before, and always start a ticket using the [JIRA Ticket Template](https://wiki.appcelerator.org/display/guides/JIRA+Ticket+Template). Thanks in advance