Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-9376] iOS: 'click' event fires on a view upon finger-down instead of finger-up

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionCannot Reproduce
Resolution Date2016-10-19T15:45:08.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsiOS
Labelscommunity, defect, ios, parity, titanbeta
ReporterShawn Lipscomb
AssigneeEric Merriman
Created2012-05-31T06:23:53.000+0000
Updated2017-03-23T19:02:27.000+0000

Description

Problem

The 'click' event of a view fires when the view is touched, even before the finger (or mouse) is released. A true 'click' does not (should not) exist until the component receives a mouse-down followed by a mouse-up without the mouse moving in between. The iOS implementation is not adhering to this definition.

Expected behavior

When you touch and hold your finger (or mouse) down on a view, only the touchstart, longpress, and longclick (Android only) events should fire. The click event should not fire until the finger (or mouse) is lifted, and then only if the finger (or mouse) has not moved since the touch started.

Actual behavior

When you touch and hold your finger (or mouse) down on a view on the iPhone simulator, the click event fires. Works on Android correctly. Broken on iOS. Therefore, this is also a parity issue.

Testcase

app.js:
win1=Ti.UI.createWindow({havbarHidden:false,
                         layout:'vertical',
                         backgroundColor:'gray'});
vw1=Ti.UI.createView({height:80,
                      left:30,
                      right:30,
                      backgroundColor:'blue'
                     });
win1.add(vw1);
lbl1=Ti.UI.createLabel({text:'Press and hold the blue box above',
                        color:'white'});
win1.add(lbl1);

function DoClick()
{
  alert('View got clicked');
}
vw1.addEventListener('click',DoClick);
win1.open();

Comments

  1. Shawn Lipscomb 2013-03-12

    Duplicated by TIMOB-11866, but note that there is a side effect of the fix to TIMOB-11866: if a slow click is performed (where the click lasts longer than half a second), the click event doesn't fire at all. I think the click even should fire in this case unless there is a longpress event assigned to the same view.
  2. Hans Knöchel 2016-10-19

    Cannot reproduce with 5.5.1.GA and iOS 10 anymore. Demo:
       var win1 = Ti.UI.createWindow({
           havbarHidden: false,
           layout: 'vertical',
           backgroundColor: 'gray'
       });
       
       var vw1 = Ti.UI.createView({
           height: 80,
           left: 30,
           right: 30,
           backgroundColor: 'blue'
       });
       
       var lbl1 = Ti.UI.createLabel({
           text: 'Press and hold the blue box above',
           color: 'white'
       });
       
       win1.add(vw1);
       win1.add(lbl1);
       
       vw1.addEventListener('click', function() {
           alert('View got clicked');
       });
       
       win1.open();
       
  3. Lee Morris 2017-03-23

    Closing ticket with reference to the above comments.

JSON Source