HISE Logo Forum
    • Categories
    • Register
    • Login

    Button.setValue(1) oninit not reflected in UI

    Scheduled Pinned Locked Moved General Questions
    14 Posts 5 Posters 254 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.
    • CyberGenC
      CyberGen
      last edited by

      Hi,

      I'm encountering an issue where using setValue(1) on a button component does not visually update the button state, even though getValue() correctly returns 1. Here's a minimal example to replicate the problem:

      const var button = Content.getComponent("Button1");
      button.setValue(1);
      Console.print(button.getValue()); // Prints 1
      

      While the console confirms that the button's value has been set to 1, the button does not visually reflect the change. Is there an additional step required to trigger the visual update for button components?

      ulrikU Dan KorneffD 2 Replies Last reply Reply Quote 0
      • ulrikU
        ulrik @CyberGen
        last edited by

        @CyberGen you need to set button.changed() as well, however the .changed() will not work during the onInit callback.

        Where do you set the value change?

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

        CyberGenC 1 Reply Last reply Reply Quote 0
        • CyberGenC
          CyberGen @ulrik
          last edited by

          @ulrik I'm currently setting the value in oninit. I'd like the button to start in the on position. I had tried the .changed() as well as setting the default value property to 1, but neither of those did the trick.

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

            @CyberGen does it have "saveInPreset" enabled?
            In that case it will remember the value you set when you save the project

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

            CyberGenC 1 Reply Last reply Reply Quote 0
            • Dan KorneffD
              Dan Korneff @CyberGen
              last edited by

              @CyberGen What about calling the change after a delay?

              Content.callAfterDelay(500, function(){
                   Knob1.setValue(1);
                   Knob1.changed();
              }, this);
              

              Dan Korneff - Producer / Mixer / Audio Nerd

              CyberGenC 1 Reply Last reply Reply Quote 1
              • CyberGenC
                CyberGen @Dan Korneff
                last edited by

                @Dan-Korneff & @ulrik So, enabling "Save in Preset" works, but I didn’t want to rely on that for this, primarily because patches can be edited and that could mess with the initial setup that I'm looking for.

                I wasn’t aware of the callAfterDelay() function. That did the trick—thank you for the tip!

                I have to say, though, it’s still a convoluted way to achieve this, especially considering how many buttons I’d need to set it up for. I’m still wondering why simply setting the default value doesn’t work with script buttons. It seems to work fine with other components.

                1 Reply Last reply Reply Quote 0
                • CyberGenC
                  CyberGen @ulrik
                  last edited by

                  @ulrik So I just realized, what you are saying here is that I should turn off the save in preset mode. That makes the setValue work. But not the default value.

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

                    @CyberGen The default value of buttons seems to not be useful. If a control is set to saveInPreset then anything you set in on init will be overwritten immediately after by the stored value.

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

                    VirtualVirginV 1 Reply Last reply Reply Quote 0
                    • VirtualVirginV
                      VirtualVirgin @d.healey
                      last edited by

                      @d-healey I can confirm that the default value for buttons is not working here either.

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

                        @VirtualVirgin said in Button.setValue(1) oninit not reflected in UI:

                        is not working

                        What do you expect it to do?

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

                        VirtualVirginV 1 Reply Last reply Reply Quote 0
                        • VirtualVirginV
                          VirtualVirgin @d.healey
                          last edited by

                          @d-healey If I set the default value to "1" and recompile I would expect the button to be on.
                          Is that not what it is meant to do?

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

                            @VirtualVirgin said in Button.setValue(1) oninit not reflected in UI:

                            Is that not what it is meant to do?

                            It doesn't do that for any other control. With slider the default value is the value it will reset to when you double click it.

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

                            VirtualVirginV 1 Reply Last reply Reply Quote 0
                            • VirtualVirginV
                              VirtualVirgin @d.healey
                              last edited by

                              @d-healey Right, I see. What is it meant for then?

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

                                @d-healey said in Button.setValue(1) oninit not reflected in UI:

                                The default value of buttons seems to not be useful.

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

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

                                42

                                Online

                                1.7k

                                Users

                                11.7k

                                Topics

                                101.9k

                                Posts