HISE Logo Forum
    • Categories
    • Register
    • Login

    Slider + ShiftKey

    Scheduled Pinned Locked Moved General Questions
    15 Posts 4 Posters 253 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • LindonL
      Lindon
      last edited by

      trying to work out how to identify if the shift key is pressed whilst moving a slider...

      mySlider.setKeyPressCallback()

      has the usual levels of documentation.... but I have discovered it at least gives me an on click event - but I cant see how I know which component its happening to -- and if any other Alt- Shift Ctl- Cmd- key is pressed.

      Anyone know how to do this outside of using a panel(i.e. using a "normal" slider)?

      HISE Development for hire.
      www.channelrobot.com

      ulrikU 2 Replies Last reply Reply Quote 0
      • ulrikU
        ulrik @Lindon
        last edited by

        @Lindon if I remember this is normal keys

        obj.keyCode
        

        and special keys

        obj.specialKey
        

        Hise Develop branch
        MacOs 15.3.1, Xcode 16.2
        http://musikboden.se

        LindonL 1 Reply Last reply Reply Quote 0
        • LindonL
          Lindon @ulrik
          last edited by

          @ulrik said in Slider + ShiftKey:

          @Lindon if I remember this is normal keys

          obj.keyCode
          

          and special keys

          obj.specialKey
          

          well I have no idea what you are doing there....

          so this code:

          inline function onVolumeKeyPress(obj)
          {
          	Console.clear();
          	Console.print("keypress event"+ trace(obj));
          }
          

          generates this on mousedown:

          Interface: keypress event{
            "isFocusChange": true,
            "hasFocus": false
          }
          

          and if I press shift and mouse down - I get exactly the same thing...so nothing useful

          HISE Development for hire.
          www.channelrobot.com

          ulrikU 1 Reply Last reply Reply Quote 0
          • ulrikU
            ulrik @Lindon
            last edited by

            @Lindon I can only log:

            "isFocusChange": true,
              "hasFocus": false
            

            from a slider keypresscb

            that must be a bug or me doing something wrong as usual?

            Hise Develop branch
            MacOs 15.3.1, Xcode 16.2
            http://musikboden.se

            d.healeyD Christoph HartC 2 Replies Last reply Reply Quote 0
            • d.healeyD
              d.healey @ulrik
              last edited by

              I'm pretty sure I added something like Content.isShiftDown. I'll check when I'm at computer in a little while.

              Libre Wave - Freedom respecting instruments and effects
              My Patreon - HISE tutorials
              YouTube Channel - Public HISE tutorials

              LindonL 1 Reply Last reply Reply Quote 0
              • Christoph HartC
                Christoph Hart @ulrik
                last edited by Christoph Hart

                A modifier key is not propagated as key press event, so you're barking up the wrong tree.

                Using a broadcaster that listenens to mouse events is super trivial:

                const var bc = Engine.createBroadcaster({
                  "id": "ShiftWatcher",
                  "colour": -1,
                  "args": ["component", "event"]
                });
                
                bc.attachToComponentMouseEvents("Knob1", "Clicks, Hover & Dragging", "watch shift events");
                
                /** just a dummy function that colours the knob based on whether the shift key is pressed or not. */
                bc.addComponentPropertyListener("Knob1", ["itemColour", "itemColour2"], "change the colour", function(index, component, event)
                {
                    return event.shiftDown ? Colours.red : Colours.blue;
                });
                
                ulrikU LindonL 2 Replies Last reply Reply Quote 0
                • ulrikU
                  ulrik @Lindon
                  last edited by

                  @Lindon I can see the slider is not working as a panel, this is an old excerpt that I used before for panels
                  Assigning a slider and try to log the "obj" will crash Hise

                  HiseSnippet 1172.3ocsV8+SaaDE+Lf2p8VmVk1e.tLoJGsRHosqchHzBDBUQLnQDJp7Kq5h8Kw23xcV1mgFMw+y6+fs2c1IwIjvlhFV.h6du289799qahL.RSkIDKmKFGCDqu0t2XgJpUDkIHcNhX8DaNSDJEjCGGSSSgPhk0luWS0xYKh46u90CobpH.lcEgbojE.+FaDSM61tMOgw4GSCgKXiJw8aZ1IPJZI4xLDIaZWiDSCtlNDNipYaCah0W0NjojI8TTEjRr15PY33dQxaE47eIKk0mC5C0I8vGJ+5ik7PMh02RZEw3gcmXwoD7U5Ny92L29+A6SYgro2OyO78FBdyjnr+vZi4g2lyAu5kgWsRvaIPxpDj1JGROytWPBKVMihFOeicGgBRFPQ2dYnjyKYiez1tkD4PnpNhdMbbBdXpD9usVsW5g+oRCWWz0mp7tgl3kxYgPh29dSjbHnZIGEKE3A+syIuMJyLQhoBfuRILT0Bfe6tqy6AAjP4dm.i6lflRKJm2GizN6rpuBMcR2VnN7GjIBTLovW1+Op349mtNrA5+uJK8XYPVJFsDCgJtNNpHVZ0PphVMhlSCkWy4jiMPlbbc.dJ35fOjCZ.oRNTMNggHWkn8RZ0TQyI9S5sLUPjQaWCiaICM5QKoS.ME7d061yY2c8Z2q0Acaum2Q.GTfmJB+E9hx6EuviKSAit0xTBgF566s81MlQXJu9UZr.6kLnATD9knmBpKo7Lv2PnPx9I.85FSwY8Wav44su3imel2IsuZOCvLHcf4cohPO7kvvK9TKnbAbaLF4.Mfm2Bdb.+J8RKZUEt+COn0I85dPKLBbNLRdStcwoXNTPDECpXAfQd1.O+Ed7muuWlHDFvDPXECSln6R.w7WTMMqepBSaF5iEUKPiChgpncpWXO2s.3QHePbLfdbpXrmPJ1IMFBXXMxbvEQEMiq1q.59OWmFVvIVLUYo37mxy3m9PMbLo7ZLf+3lydfojIzDobcR.UVhvSkjgQl6L0s4E85nyhUs9XUIxhoF+An65Nor0SJNSpfOH7qnqccuy0aQRCFrTZ5tKIRNGRVJY8zjjGRPeQ1n9PxKyyomxH1hc9911qtuc4wJA4M6JwnTzQvTe.ijqZXConCotGeApPVUlN7eWQG9dFeMgEpG6l63IFDWdvJ4icNBiwSdG7IQ0DCIJl1BrNBtAG7lO4vw9HH8ZkLFmgNsqLNK8eWqeYlFup43xGtkEphlcwu2LBXCiJMjuSSx800SmLCSmrXT0WaaRbVolXKpoqtmltpI49SKw4zxvLNUM+va8FKEDXKrLidpnHkoFWdil+2ln+eEhOytqd.yxw3FKAiXBviAFK1C5o1sGL.BTy.3V1G+oGmkdHmKyTX6ySoXWTLev9rrQ8vUAC.8.cLIQWYZsgtFJ+bM8YsGnG14zb3uwuBh00msJHVeBQxHZPh7yA4Ud5Msdh4FDSByRlN1mpO6UeREmscsp0Hivk99bPf172AKqWtLuZMj40qgLuYMj4mWCYd6ZHy6VCY9kGTF891GjojixKGvK511z4yxpsfhYVlrPx+.Tal98A
                  

                  Hise Develop branch
                  MacOs 15.3.1, Xcode 16.2
                  http://musikboden.se

                  1 Reply Last reply Reply Quote 0
                  • ulrikU
                    ulrik @Christoph Hart
                    last edited by

                    @Christoph-Hart Ok, so the old concept KeyPress is not valid for at least sliders?

                    Hise Develop branch
                    MacOs 15.3.1, Xcode 16.2
                    http://musikboden.se

                    Christoph HartC 1 Reply Last reply Reply Quote 0
                    • LindonL
                      Lindon @d.healey
                      last edited by

                      @d-healey said in Slider + ShiftKey:

                      I'm pretty sure I added something like Content.isShiftDown. I'll check when I'm at computer in a little while.

                      well this would be the simplest - so if you can look it up that would be great

                      component.isShiftDown() < -- doesn't appear to be it...

                      HISE Development for hire.
                      www.channelrobot.com

                      1 Reply Last reply Reply Quote 0
                      • Christoph HartC
                        Christoph Hart @ulrik
                        last edited by

                        That hasn't changed. Modifier keys (alt, shift, ctrl) are never propagated as key strokes (not just for sliders, everytime), otherwise a key stroke like "ctrl+c" would always be two calls and you need to discard the first.

                        Lindon wants to know whether a modifier key is pressed while dragging the mouse, so the logical solution is to use a mouse event broadcaster.

                        ulrikU 1 Reply Last reply Reply Quote 1
                        • ulrikU
                          ulrik @Christoph Hart
                          last edited by

                          @Christoph-Hart Ok, thanks!

                          Hise Develop branch
                          MacOs 15.3.1, Xcode 16.2
                          http://musikboden.se

                          1 Reply Last reply Reply Quote 0
                          • LindonL
                            Lindon @Christoph Hart
                            last edited by Lindon

                            @Christoph-Hart said in Slider + ShiftKey:

                            A modifier key is not propagated as key press event, so you're barking up the wrong tree.

                            Using a broadcaster that listenens to mouse events is super trivial:

                            const var bc = Engine.createBroadcaster({
                              "id": "ShiftWatcher",
                              "colour": -1,
                              "args": ["component", "event"]
                            });
                            
                            bc.attachToComponentMouseEvents("Knob1", "Clicks, Hover & Dragging", "watch shift events");
                            
                            /** just a dummy function that colours the knob based on whether the shift key is pressed or not. */
                            bc.addComponentPropertyListener("Knob1", ["itemColour", "itemColour2"], "change the colour", function(index, component, event)
                            {
                                return event.shiftDown ? Colours.red : Colours.blue;
                            });
                            

                            so to add multiple sliders i just say this?

                            bc.addComponentPropertyListener(["Knob1","Knob2","Knob3"], ["itemColour", "itemColour2"], "change the colour", function(index, component, event)
                            

                            and this?:

                            bc.attachToComponentMouseEvents(["Knob1","Knob2","Knob3"], "Clicks, Hover & Dragging", "watch shift events");
                            

                            HISE Development for hire.
                            www.channelrobot.com

                            Christoph HartC 1 Reply Last reply Reply Quote 0
                            • Christoph HartC
                              Christoph Hart @Lindon
                              last edited by Christoph Hart

                              Sure. However then you need to figure out which component is currently dragged so you need to use the index and this object in the function (also you need to check the event.drag flag.

                              const var bc = Engine.createBroadcaster({
                              	"id": "ShiftWatcher",
                              	"colour": -1,
                              	"args": ["component", "event"]
                              });
                              
                              /** No need to define multiple arrays... */
                              const var bcTargets = ["Knob1", "Knob2", "Knob3"];
                              
                              bc.attachToComponentMouseEvents(bcTargets, "Clicks, Hover & Dragging", "watch shift events");
                              
                              /** the index can be used to check the component argument against the `this` object of the function (= the component array). */
                              bc.addComponentPropertyListener(bcTargets, ["itemColour", "itemColour2"], "change the colour", function(index, component, event)
                              {
                                  // index is -1 if you don't pass in an array so this will cover all cases...
                                  var isSameComponent = index == -1 || (this.length > 0 && this.indexOf(component) == index);
                              
                                  return isSameComponent && event.drag && event.shiftDown ? Colours.red : Colours.blue;
                              });
                              
                              LindonL 1 Reply Last reply Reply Quote 1
                              • LindonL
                                Lindon @Christoph Hart
                                last edited by

                                @Christoph-Hart thanks.

                                HISE Development for hire.
                                www.channelrobot.com

                                1 Reply Last reply Reply Quote 0
                                • d.healeyD
                                  d.healey
                                  last edited by

                                  The broadcaster is nice, but overkill for this simple task.

                                  In one of my scripts I'm using Content.isCtrlDown() and it does the trick nicely. I don't know if this is just a feature in my fork or if it was merged into the main codebase. Either way if there is demand I could add a .isShiftDown and .isAltDown function too.

                                  Libre Wave - Freedom respecting instruments and effects
                                  My Patreon - HISE tutorials
                                  YouTube Channel - Public HISE tutorials

                                  1 Reply Last reply Reply Quote 1
                                  • First post
                                    Last post

                                  35

                                  Online

                                  1.7k

                                  Users

                                  11.7k

                                  Topics

                                  102.0k

                                  Posts