(Resolved) Help: Ng-Touch: Touch Screen commands

Hi All,

I have an Item defined as follows:

Switch Gate "Front Gate" [ "Lighting" ] {mqtt=">[brokerHome:/topics/sonoff/one:command:off:0],>[broker:/topics/sonoff/one:command:on:1]"}

In HabPanel i have a custom switch defined using ng-mousedown and ng-mouseup, my issue is that it seems a finger touch screen “touch” does not behave the same as a mouse click.

    <div ng-init='onoff={"name": "OnOff", "item": config.light, "hidelabel": true, "hideonoff": true, "iconset": "smarthome-set","icon": "bulb","icon_size": "36" }'>                
        <widget-switch  ng-model="onoff" ng-mousedown="sendCmd(config.light, 'ON')" ng-mouseup="sendCmd(config.light, 'OFF')"/>
      <!--<widget-switch  ng-model="onoff" ng-touchstart="sendCmd(config.light, 'ON')" ng-touchend="sendCmd(config.light, 'OFF')"/> -->
     </div>

I have tried to use the ng-touch function, however it seems to give the same issues.

Basically what i’m trying to achieve is that when the button is touched it must send the on command, and when it is released it sends the off command, basically a momentary switch.

Any better ideas to get the button to reset when you lift your finger?

Just to elaborate a bit more, using a mouse works 100% as expected, using a finger / touch the panel does not recognize that I’ve lifted my finger so “mouseup” never fires.

Adding to this, it seems its a problem with the long press in the browser where it thinks it needs to open the context menu, attempting to block this in habpanel, not sue yet how though.

Found a workaround solution, added a rule that send the off command after 1s.

var Timer timer = null
val Random random = new Random()


rule "GateC"
when
    Item Gate received command
then
    if(receivedCommand==ON) {
        if(timer==null) {
                timer = createTimer(now.plusSeconds(1)) [|
                sendCommand(Gate, OFF)
          ]
        timer=null
        }
    }
end