Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-10985] Android: Holding button down cancels 'singletap' event listener

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionInvalid
Resolution Date2018-01-03T03:27:07.000+0000
Affected Version/sRelease 3.0.0
Fix Version/sn/a
ComponentsAndroid
Labelsapi, exalture, longpress, parity, singletap
ReporterMartin Guillon
AssigneeMaggie Chen
Created2012-09-04T05:40:48.000+0000
Updated2018-01-03T03:27:07.000+0000

Description

Problem

Looking at the logcat, I get that message every time I "longpress" - 09-04 14:45:26.052: W/TextView(623): TextView does not support text selection. Action mode cancelled. If i get that message then I dont get the singletap event.

Tested on

Confirmed on Samgsung Galaxy Tab Android OS 3.2

Test case

var win = Ti.UI.createWindow({ backgroundColor: '#fff' });

var label = Ti.UI.createLabel({
    text: 'Touch the Button!', textAlign: 'center',
    top: 0, right: 0, bottom: '50%', left: 0
});
win.add(label);

var button = Ti.UI.createButton({
    title: 'Update Label',
    top: '50%', right: 0, bottom: 0, left: 0
});
win.add(button);

var launch = new Date().getTime();
button.addEventListener('singletap', function() {
    label.text = parseInt((new Date().getTime() - launch) / 100) / 10 + ' seconds since app launched.';
});

win.open();

Comments

  1. Eduardo Gomez 2012-09-12

    Not seeing the actual device this was tested on, but basically onSingleTap event is notified when a tap occurs with the up MotionEvent that triggered it. MotionEvent overview: Some devices can report multiple movement traces at the same time. http://developer.android.com/reference/android/view/MotionEvent.html Do you get the same result if using a click event listener?
       var button = Titanium.UI.createButton({
          title: 'Hello',
          top: 10,
          width: 100,
          height: 50
       });
       button.addEventListener('click',function(e)
       {
          Titanium.API.info("You clicked the button");
       });
       
  2. Martin Guillon 2012-09-17

  3. Eduardo Gomez 2012-09-18

  4. Daniel Sefton 2012-09-18

    Tested and confirmed on Samgsung Galaxy Tab Android OS 3.2. To clarify: 'singletap' is not fired and the message "TextView does not support text selection. Action mode cancelled." appears in logcat when holding the button down for longer than a tap gesture. It is fired with no message when tapping without holding.
  5. Martin Guillon 2012-09-18

    @Eduardo: You are right the 2 other bugs where on ios, yes. But in a multi platform situation, having singletap and click problems is not that good. That s what i wanted to point out. As for the device, if i didnt mention device/simulator, is because it was clearly happening on both. Especially as i pointed out that it certainly was just a question of implementation. Thanks for your feedback
  6. Eduardo Gomez 2012-09-19

    Format corrected, added the test device & parity label. Moving to Titanium Project to dig into it - it's potentially native behavior.
  7. Martin Guillon 2012-10-16

  8. Maggie Chen 2017-09-21

    Hi in your case the long press was handled by longpress event rather than singletap event.
       var win = Ti.UI.createWindow({ backgroundColor: '#5ff' });
       
       var label = Ti.UI.createLabel({
           text: 'Touch the Button!', textAlign: 'center',
           top: 0, right: 0, bottom: '50%', left: 0
       });
       win.add(label);
       
       var button = Ti.UI.createButton({
           title: 'Update Label',
           top: '50%', right: 0, bottom: 0, left: 0
       });
       win.add(button);
       
       var launch = new Date().getTime();
       button.addEventListener('singletap', function() {
           label.text = parseInt((new Date().getTime() - launch) / 100) / 10 + ' seconds since app launched.';
       });
       
       button.addEventListener('longpress', function() {
           label.text = parseInt((new Date().getTime() - launch) / 100) / 10 + ' seconds longpress fired.';
       });
       
       win.open();
       

JSON Source