Forum
    • Categories
    • Register
    • Login

    Crazy question, Is it possible to change a knob from slide to click (there is button, but testing something)

    Scheduled Pinned Locked Moved General Questions
    13 Posts 4 Posters 80 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.
    • Y
      Yannrog @David Healey
      last edited by

      @David-Healey Hello @David-Healey

      Thank you, It works fine !

      So now It has the possibility to slide or click. This is good. Thank you David.

      I put a if clicked, value (64)

      however, how to add a statement : if clicked again (value 65),

      And so on, if click, set 64, if click again, set 65

      David HealeyD dannytaurusD 2 Replies Last reply Reply Quote 0
      • David HealeyD
        David Healey @Yannrog
        last edited by

        @Yannrog Why not use a button for that?

        Free HISE Bootcamp Full Course for beginners.
        YouTube Channel - HISE tutorials
        My Patreon - More HISE tutorials

        Y 1 Reply Last reply Reply Quote 1
        • dannytaurusD
          dannytaurus @David Healey
          last edited by

          @David-Healey FWIW, it looks a slider does trigger a callback on a slider click (no move):

          A plain click with no mouse movement fires the control callback once, on mouse up, with the unchanged value.

          • Mouse up (all styles): JUCE ends its drag gesture on every click, which calls HiSlider::sliderDragEnded. That calls setAttributeWithUndo with the current value, which ends up in ProcessorWithScriptingContent::setControlValue. setControlValue calls controlCallback unconditionally, with no "did the value change" check.
          • Mouse down, Knob style: nothing fires. The rotary drag is relative to the mouse-down position, so the value does not change.
          • Mouse down, Horizontal/Vertical with showTextBox off: the value snaps to the click position, so the callback fires on mouse down with the new value, then again on mouse up.
          • Mouse down, Horizontal/Vertical with showTextBox on: JUCE skips the snap for a plain click, so only the mouse-up callback fires.
          const var Knob1 = Content.addKnob("Knob1", 0, 0);
          
          reg count = 0;
          
          inline function onControl(component, value)
            {
              count++;
              Console.print(count + ": " + component.getId() + " = " + value);
            }
          
          Knob1.setControlCallback(onControl);
          

          Is that what you meant when you said "I don't think the callback triggers on click"?

          HISE dev latest / herdr + Claude Code / Figma + Affinity
          Meat Beats: https://meatbeats.com
          Klippr Video: https://klippr.video

          Y 1 Reply Last reply Reply Quote 1
          • dannytaurusD
            dannytaurus @Yannrog
            last edited by

            @Yannrog If you're using clicks on knobs/sliders, be careful of the default 'double-click to reset' action.

            HISE dev latest / herdr + Claude Code / Figma + Affinity
            Meat Beats: https://meatbeats.com
            Klippr Video: https://klippr.video

            1 Reply Last reply Reply Quote 0
            • Y
              Yannrog @David Healey
              last edited by

              @David-Healey How to change the default value of a knob, instead of 0, 1?

              David HealeyD 1 Reply Last reply Reply Quote 0
              • David HealeyD
                David Healey @Yannrog
                last edited by

                @Yannrog knob or button? If a button you would use a hidden knob to store the value and use the button to increment it. But since it seems like knobs respond to clicks that might be there better way to go after all.

                Free HISE Bootcamp Full Course for beginners.
                YouTube Channel - HISE tutorials
                My Patreon - More HISE tutorials

                Y 1 Reply Last reply Reply Quote 0
                • Y
                  Yannrog @David Healey
                  last edited by

                  @David-Healey Thank you,

                  The simplest would be a button that as value 64, 65 instead of 0, 1.

                  The knob is a plus. The button is actually fine

                  David HealeyD 1 Reply Last reply Reply Quote 0
                  • David HealeyD
                    David Healey @Yannrog
                    last edited by

                    @Yannrog A button only has two values. If you don't need the value to be saved in preset then you can use the button to increment a variable. Otherwise you'd need another control to store the value - either a knob or a panel.

                    If it was me I'd use a panel, but it might be easier for you to use a knob. @dannytaurus Pretty much gave you the code you need above.

                    Free HISE Bootcamp Full Course for beginners.
                    YouTube Channel - HISE tutorials
                    My Patreon - More HISE tutorials

                    Y 1 Reply Last reply Reply Quote 0
                    • Y
                      Yannrog @dannytaurus
                      last edited by

                      This post is deleted!
                      1 Reply Last reply Reply Quote 0
                      • Y
                        Yannrog @David Healey
                        last edited by

                        Thank you @David-Healey @dannytaurus , this is almost there.

                        However, is it possible to add a statement to this line?

                        {

                        if (event.clicked)
                        
                        component.setValue(64);
                        

                        The other statement should be something like

                        if the value is already set to 64 when clicked again, set to 63.

                        Is it possible ? or is there another way to do it? Like switching between this 2 values 64 and 63 ?

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

                          @Yannrog I don't know if I missed some information but, if you only need to switch between 2 different values from a button set it up like this:

                          inline function onBtnControl(component, value)
                          {
                          	local v = value ? 64 : 63;
                          	Console.print(v);
                          	//	control something with v
                          };
                          
                          Content.getComponent("Btn").setControlCallback(onBtnControl);
                          

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

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

                          12

                          Online

                          3.1k

                          Users

                          14.0k

                          Topics

                          122.1k

                          Posts