HISE Logo Forum
    • Categories
    • Register
    • Login

    Help with Broadcaster to make componets visible and enabled

    Scheduled Pinned Locked Moved Scripting
    4 Posts 2 Posters 292 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.
    • O
      Onik Sisodiya
      last edited by

      I have 2 arrays one with btns and another one with knobs

      Btns = [btn1, btn2, btn3]
      Knbs = [knb1, knb2, knb3]

      I want to hide the knb according to the btn's value, If btn1 is on or has a. value of 1 then the knb1 should be visible and enabled. I tried this without using a broadcaster but with a callback function using the knb.set("visible", true); But the thing with this is that when I switch the preset it hides the knb even when the button is active. I think using a broadcaster can fix it as by switching presets it will update those knbs and btns in the backend.

      I would really appreciate if someone can help me with this

      ulrikU O 2 Replies Last reply Reply Quote 0
      • ulrikU
        ulrik @Onik Sisodiya
        last edited by

        @Onik-Sisodiya so this will not work when switching presets?

        inline function onBtnsControl(component, value)
        {
        	local idx = Btns.indexOf(component);
        	
        	Knbs[idx].showControl(value);
        	Knbs[idx].set("enabled", value);
        }
        
        for (b in Btns)
        	b.setControlCallback(onBtnsControl);
        

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

        1 Reply Last reply Reply Quote 0
        • O
          Onik Sisodiya @Onik Sisodiya
          last edited by

          @Onik-Sisodiya Thanks @ulrik for the snippet. I have the similar callback for the functionality but however when switching the preset it hides the knb even when the button is active. But I gave a try with a broadcaster and attached a knob and a button and it looks like it works perfectly. I'm afraid I don't have to use a seperate broadcaster for pair of button annd a knob.

          // Broadcaster definition
          const var btnknb = Engine.createBroadcaster({
          "id": "btnknb",
          "args": ["component", "value"],
          "tags": []
          });

          // attach to event Type
          btnknb.attachToComponentValue(["SendAmountOnOff3"], "");

          // attach first listener
          btnknb.addComponentPropertyListener(["AmountWheel3"], ["visible", "enabled"], "dsas", function(index, component, value){
          return value;
          });

          Like this, If there's anyway to make it maintainable and with less code would be really helpful.

          O 1 Reply Last reply Reply Quote 0
          • O
            Onik Sisodiya @Onik Sisodiya
            last edited by

            @Onik-Sisodiya Just got it figured out!! Thanks again

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

            74

            Online

            1.7k

            Users

            11.7k

            Topics

            102.2k

            Posts