Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-17955] onClick event is not fired/called when the same button is clicked immediately

GitHub Issuen/a
TypeBug
PriorityNone
StatusOpen
ResolutionUnresolved
Affected Version/sRelease 3.3.0, Release 3.4.0
Fix Version/sn/a
ComponentsiOS
LabelsTCSupport, ios
ReporterIvan Bautista
AssigneeUnknown
Created2014-09-17T12:48:40.000+0000
Updated2021-01-03T16:12:44.000+0000

Description

Problem Description

When clicking the same imageview continuously, onClick event of the imageview is called on the first click but not on succeeding clicks. Only if you wait for a few milliseconds to a second, before clicking again the same imageview, will the onClick event be fired/called. To be able to replicate this, the same imageview should be clicked immediately and continuously. To test this, I created a test project which contains an imageview and a label, which serves a counter. Every time the imageview is clicked, the counter label increments, which somehow corresponds to how many times it was clicked. When I click the imageview immediately and continuously, the counter label doesn't increment anymore after the first increment. But if I wait a few milliseconds/seconds before clicking again, then the counter label increments.

Steps to reproduce

1. Create a classic Titanium project 2. Add code to app.js:
var win = Titanium.UI.createWindow({  
    backgroundColor:'#fff',
    layout:'vertical'
});
 
var anImageView = Ti.UI.createImageView({
    image : '/image.png',
    width : 'auto',
    height : 'auto',
    top : 20,
});
 
var count=0;
 
var aLabel = Ti.UI.createLabel({
    text : '0',
    color : '#000',
    font : {fontSize:18},
    height : 'auto',
    width : 'auto',
    top : 10,
    textAlign : 'center'
});
 
anImageView.addEventListener('click', function() {
    count++;
    aLabel.text=count;
});
 
win.add(anImageView);
win.add(aLabel);
win.open();

Comments

  1. Mauro Parra-Miranda 2014-09-17

    Hello [~ibautista.lancera]! Please read the guide to create JIRA issues [here](https://wiki.appcelerator.org/display/guides2/How+to+Submit+a+Bug+Report#HowtoSubmitaBugReport-SubmittingTickets), your report lacks: - Minimal Sample Code that reproduces the issue (i.e., in this case you talk about a image view; you can create a new mobile project in classic titanium and add a imageview with the included icons in the sample default project -two tabbed-). - Please provide all the info related to this: Ti Mobile SDK version, iOS version, Xcode Version, etc. Thanks!
  2. Ivan Bautista 2014-09-18

    Updated the description and created a simple test project that replicates the issue.
  3. Ivan Bautista 2014-09-23

    Any Uopdates on this @Mauro Parra-Miranda?
  4. John Staunton 2021-01-02

    Issue raised over 6 years ago, still exists as an issue today (iOS only, fine on Android)... debounce seems to exist on the event listener for iOS view clicks...
  5. Michael Gangolf 2021-01-03

    [~john.staunton] just use singletap on iOS. Than you can click as fast as you can
  6. John Staunton 2021-01-03

    @Michael Gangolf, this is something I also tried - it's marginally better than 'click' but when doing some background processing after each click it still seems to have a debounce / inaccuracy. Instead, I've overlaid a transparent button on the view and used the onSingletap there as part of the button view controller - seems much more accurate than the addEventListener way...

JSON Source