Long press activated widget

Hi,

I’m looking for a widget that act on long press.
Is there such widget?

Thanks!

no there is not.
long press in a dashboard would be the same as a doubleclick on the PC.
at the moment there where no functions that would benifit from that.

if you are looking for keeping a button pressed for an amount of time (to keep something working) then that wont be possible at all, because off the delays and speeddifferences in loading, communicating, etc. that would be unreliable.

If you mean a widget that activates an entity while the widget is pressed and deactivates the entity when you release, I made one to control a cover. Like Rene points out, there are some timing issues due to roundtrip delays, but for controlling a cover, it works fine. See the .js part of the widget here. https://hastebin.com/ufaboqacuw.php

This only works on an ipad/tablet or a touch screen laptop.

1 Like

slow moving elements can be done, but for instance for most dimming functions it wouldnt work.

nice js file by the way.

Yes, very erratic behaviour when used for dimming, I tried :slight_smile: But for slow moving things, works fine.

there are also press and release options for mouseclicks (touch is nothing else) that could be used.
for me its no option either, my tablet/wifi is just to slow

Yes, you would just need to replace touchsurface.addEventListener('touchmove', async function(e) with touchsurface.addEventListener('mousedown', async function(e) in the code and the same for “touchend” / “mouseup”.

could be, but you didnt make use of the things that are already there.
Andrew added callback options.

from the switch widget:

    self.OnButtonClick = OnButtonClick;
    
    if ("enable" in self.parameters && self.parameters.enable == 1)
    {
        var callbacks =
            [
                {"selector": '#' + widget_id + ' > span', "action": "click", "callback": self.OnButtonClick},
            ]
    }            
    else
    {
        var callbacks = []
    }        

if you replace click by mousedown it would do the trick also :wink:

Aha! I used my code originally to make a slider that you can control by swiping so I needed to get the x/y positions on touchstart, touchmove and touchend and then I just reused it for the cover button. This is of course more elegant for just catching a press/release.

1 Like