Announcement

Collapse
No announcement yet.

HSTOUCH Long press or double click functions on buttons ?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    HSTOUCH Long press or double click functions on buttons ?

    Is there an easy way to implement long press or double click functions on HStouch buttons (other than using custom scripts or multiple timers/events in HS3) ?

    Otherwise let me know what are your ideas/workarounds as I could make good use of such features but want to minimize implementation/management efforts.

    So far, I managed to do it with two HSTouch actions (start on press / reset on release) and three HS3 events (Start timer on press, trigger after 1sec. reset to zero on release)

    Thank you!

    #2
    Have you thought about using a slider with ranges to indicate long press, double click etc. It's kind of kludgey but should reduce the number of events needed.

    Comment


      #3
      Thx for the suggestion but not totally sure how this would be simpler; would you mind providing more details?

      Comment


        #4
        I was assuming you wanted to drive an events, scenes, or scripts with the different presses. I am not aware of any mechanism built into hstouch to allow this directly.

        Use the slider to drive a virtual device. Trigger the event/scene/script off of the virtual device. Values between 1 and 50% would represent long press. Values > 50% would represent double click.

        You could do the same with two radio buttons if that is cleaner for your interface. A drop down list could be made to do similar things and it would all be in a single element.

        Comment


          #5
          The trouble with using timers and such to determine long presses, etc, is that if the system is bogged down for some reason, a short press could be confused with a long press. I use timers on my Android phone (with Tasker) for long presses and double presses, and occasionally this does happen.

          I have thought about doing something similiar by utilizing a "Shift" key (i.e. Shift button). It would only work when initiating HS Events though.

          The Shift key would control a Virtual Switch "Shift", toggling it on or off. Then I would have three events:

          Event ButtonPress (initiated by HS Touch button)

          If Manually Triggered
          Then
          If Conditions Are True, run event ButtonPressUnshift
          If Conditions Are True, run event ButtonPressShift

          Event ButtonPressUnshift

          If Manually Triggered
          AndIf Shift = Off
          Then <do unshift tasks>

          Event ButtonPressShift

          If Manually Triggered
          AndIf Shift = On
          Then <do shift tasks>

          I suppose that "Shift" virtual switch could have multiple states (off, on, extraon, extraextraon, etc), and cycle between those states.

          Have not actually implemented this yet, still deciding if it would be useful or not.

          Comment


            #6
            AllHailJ: The intent is to use multiple functions on the same button; I do use drop down lists for scenes (even though HSTouch still has bugs with the feature. I use separate screens on top as a workaround).

            aa6vh: Thanks for the feedback, funny as this is exactly what I ended up implementing yesterday =) Simple and efficient.
            Long press also works well but requires a little more programming.

            Still would be nice to have "long press" & "double click" as standard features in HStouch....

            cheers,

            Comment


              #7
              I did have an idea that might be of use and not so kludgey. Place buttons on the screen or a pop up to represent shift, ctrl, alt and windows. When you press one of the buttons, it sets a virtual device to shift, ctrl, alt, windows. This would allow 5 actions for a single button. You then would clear the virtual device at the end of the event or script. Much like typing on a keyboard. I am just trying to figure out how you track (in homeseer) what hstouch device it is coming from so you don't have collisions.

              Comment


                #8
                I was slightly bored today, and wanted to revisit this thread. Decided to do a "proof of concept" to see if a script could handle a double click on an HS Touch button (it can).

                The "cmdClick" HS Touch button has a label of "DblClick" for this example.

                In the HS Touch button action (when button released):

                Action: Run script "Click.vb"
                Parameter 1: txtTablet ' Located on main screen, holds name of this tablet
                Parameter 2: cmdClick

                Homeseer Event "Click":

                If Manually triggered
                Then
                Wait 2 seconds
                Run script "Click.vb" [Allow more than one copy to run, and do not wait for completion]

                Code:
                Private Function TouchParseStr(ByVal parms As Object, ByVal sSep As String, Optional sDef As String = "") As String()
                ' Takes the input parameter, and returns an array of strings.
                ' If called from event, parms is a single string, so does a split on the specified delimiter.
                ' If called from HS Touch, just returns the string array.
                ' Usage: Sub Main(parms As Obect)
                '          Dim p() As String = TouchParseStr(parms, ",") ' p(0) now contains first, p(1) second, etc
                  Dim buff() As String
                  If parms Is Nothing Then parms = ""
                  If parms.GetType().ToString = "System.String" Then
                    If parms = "" Then parms = sDef
                    parms = Trim(parms.ToString())
                    buff = parms.Split(sSep)
                  Else
                    buff = parms
                  End If
                  Return buff
                End Function
                Sub Main(parms As Object)
                  Dim bSingle As Boolean = True
                  Dim p() As String = TouchParseStr(parms, "|")
                  ' p(0) holds calling tablet name, p(1) holds button clicked's caption
                  Dim tsave As String = hs.GetVar("ClickTicks")
                  Dim t() As String = tsave.Split("|")
                  If p(0) = "" Then ' Return from Click Event
                    if t(0) = "-" Then Exit Sub ' Already Handled by second click
                    p = t
                  ElseIf t(0) = "-" Then ' Original Click
                    hs.SaveVar("ClickTicks", p(0) + "|" + p(1)) ' Mark "in process"
                    hs.TriggerEvent("Click") ' Event "Click" waits 2 seconds, comes back
                    Exit Sub ' Exiting necessary so that Touch can resume.
                  Else ' Double Click occured
                    bSingle = False
                    If p(0) <> t(0) Then Exit Sub ' Second clicking tablet gets ignored
                  End If
                  hs.SaveVar("ClickTicks", "-") ' Clear "in process"
                  ' Create case statement for each buton that allows double clicks:
                  Select Case p(1)
                    Case "DblClick"
                      If bSingle Then
                        hs.WriteLog("Click", "Single Click: " + p(0) + ": " + p(1))
                        ' hs.TriggerEvent("SingleClick")
                      Else
                        hs.WriteLog("Click", "Double Click: " + p(0) + ": " + p(1))
                        ' hs.TriggerEvent("DoubleClick")
                      End if
                  End Select
                End Sub
                The "TouchParseStr" function is just a standard function I use to parse the parameters (used so I can call script from an event or Touch).

                Drawbacks: The first click processing is delayed to wait to see if there is a second click. And if two people are clicking on two tablets at the same time, the second one will be ignored.

                Comment


                  #9
                  Thanks for the POC
                  added to my list of things to test. Will report back once i get there . Cheers.

                  Comment


                    #10
                    I also have my own solution with scripts but this really should be directly implemented into HSTouch which also will make it more responsive. Please put in a feature request because HS won't do anything (understandably) unless many people request it.

                    https://dev.homeseer.com/servicedesk/customer/portals

                    Comment


                      #11
                      Agreed. Will do. Thx

                      Comment


                        #12
                        I suppose that if the button is large enough that you could split the touch area into effectively two buttons but only look like one. touch the top part and get one result and the bottom part as another result.

                        Stuart

                        Comment


                          #13
                          It's not big enough. Also it makes thinks really finicky and frustrating. This really needs to be a built-in feature. In my opinion this is a very basic feature and needs to be added to HSTouch. If you feel this could be helpful for your project then please submit a feature request.

                          Comment


                            #14
                            You can check out this post to see how I did it for a keypad. Others contributed and made it clearer and prettified.

                            https://forums.homeseer.com/forum/ho...-hstouch/page3

                            I also have a keyboard detailed in the forum if you want to look at that. Here is the code for a "shift key" The same routine can support multiple keys as you pass the device reference to the routine.

                            Code:
                            'ShiftKeySet.vb
                            'The purpose of this routine is to recieve a keystroke and to append to a device to build a string.
                            'The Routine is expecting one parameters. The device to store it to.
                            '5/19/2020 JLG
                            
                            Sub Main(ByVal parms As Object)
                            
                            Dim parm As String
                            Dim dvRef As Integer 'The RefID
                            
                            If parms.GetType().ToString = "System.String" Then 'Called from an Event
                            parm = parms.ToString()
                            Else ' Called from HSTouch
                            parm = parms(0).ToString()
                            End If 'Now use parm as your input variable...
                            
                            dvRef = parm 'The Device Reference
                            
                            hs.SetDeviceValueByRef(dvRef, 1, True) 'Set the Shift key to True - Next KeyStroke will be Uppercase
                            End Sub

                            Comment

                            Working...
                            X