touchscreen press&hold

Posted on
  • I've been trying to get additional interactions compatible with bangle.js1, and i got success long press for buttons.

    However I can't find info about how to use Bangle.on('touch' and time periods.
    In the documentation there is:

    Bangle.on('touch', function(zone,e) { ... }); will call the function
    with e as an object containing {x,y} every time the screen is tapped
    (when unlocked).

    Besides "zone" and "e"(x,y) there is also "e.type" but i don't know what is its purpose.

    Any idea to apply time events for touch tap?
    Is the only possible solution at a lower level, such as digitalPulse(pin, value, time)?

  • there is also "e.type" but i don't know what is its purpose.

    It seems to be undocumented, but exactly what you're looking for: e.type==0 for short press, and e.type==2 for long press.

    Edit: Only tested it on my Bangle.js 2, so it might not work on the Bangle.js 1. Also doesn't seem to work in the emulator.

  • Are you sure?
    Then it something is failing (on bjs2 emulator) because I got always an output 0.
    And Bangle.js has not implemented the e object

  • The 'type' is from the Bangle.js 2 touchscreen controller, but I'm afraid it's not in the emulator, and won't be on Bangle.js 1.

    I guess if you want to do that you need to compare the time differences between the press+release events

  • I guess if you want to do that you need to compare the time differences between the press+release events

    Do you know about code/apps already controlling time between press+release events?
    Does it require to work at pin level?

  • I think the Layout library already does this. The long/short press functionality was requested by someone as a must-have feature but I'm not sure I'm aware of anyone actually using it to date :(

  • In a UI context, the long press vs short kick usually initiates an alternate function or a menu to select from a host of alternate functions. It became necessity when - because of Apple (2) - lost the second eye to end up as a single eyed minion. Initially, the mouse started out with 3...

    Next issue with touch vs mouse is the loss of continuous 'contact' of the pointing device indicator - and with that the mouse pointer had to go away. Luckily touch w/ move - drag - is introduced.

    Back to the long press: this could actually really increase robustness of changing settings. I experience the setting of, for example, elements of time very finicky... may be I do it wrong, but a long press on the item with a pop up that has plenty real estate to have easy usable up/down, cancel/ok controls.

    Sometimes the direct control is not worth the trouble it creates, or in other words, and extra touch at the begin and end of an operation is worth to pay to have a robust working operation. This is especially true in the fight of a fat finger on a super tiny and moving touch screen.

  • I think the Layout library already does this

    Cool and first notice of it. Time ago I tried to create a UI template to implement some of these features

    Back to the long press: this could actually really increase robustness
    of changing settings

    I want to associate the long press to a delete file operation, so a simple event is not an alternative.

  • The layout library is powerful but it is not a solution to have a long press touch event on (bangle.js2)

    Executing below code you can see that "long press" is only detected on Bangle.js1

    var v_model=process.env.BOARD;
    var Layout = require("Layout");
    if (v_model=='BANGLEJS'||v_model=='EMSCRIPT­EN')  v_font="6x8:2";    
     else v_font="6x8";
    
    var layout = new Layout( {
        //v vertical
          type:"v", c: [
            {type:"txt", font:v_font, label:".", id:"label", valign:-1, halign:-1 }
          ]
        },  {btns:[
        {label:"File", cb: l=>print("log: btn1"),  cbl: l=>{print("log: long press btn1"); },font:v_font, col:"#f00"},
        {label:"Launch", cb: l=>print("log: btn2"),font:v_font, col:"#f00"},
        {label:"Color", cb: l=>print("log: btn3"),font:v_font, col:"#f00"}
      ], lazy:true});
    
      layout.render();
    

    Is it is the expected behaviour?
    If yes, is the only alternative digitalPulse?

    I am aware of @enaon using "longpress" on his eucwatch and I see that it is through digitalPulse?

  • Executing below code you can see that "long press" is only detected on Bangle.js1

    It works fine for me... Long-pressing on "file" gives log: long press btn1

    But as I said it doesn't work in the Bangle.js 2 emulator

  • But as I said it doesn't work in the Bangle.js 2 emulator

    It has sense that low level code is common and applies also to layout. ;)

    On the other hand, I was trying to use at sametime "Layout" (for physical and on screen buttons) and "setUI" (for "back" icon+call, swipe and touch events)

    But I've realized that "layout.render()" removes the SetUI settings. Whereas "setUI()" removes the code associated to "layout btns"

    am i doing something wrong ?
    Is the expected behaviour being exclusive between them?

  • Is the expected behaviour being exclusive between them?

    Yes, it is - potentially we could change that though - maybe allowing a ui:{...} argument that would add to/override what is passed to setUI?

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

touchscreen press&hold

Posted by Avatar for dapgo @dapgo

Actions