HISE Logo Forum
    • Categories
    • Register
    • Login

    noob question: UI component.set()

    Scheduled Pinned Locked Moved Scripting
    7 Posts 3 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.
    • P
      prehm
      last edited by

      hey there,
      i have created a couple of buttons with a custom image using LAF and added these to an array.
      i edited the JSON objects in the component list to have an extra property called "group", which i intend to change on a control callback and then use inside the LAF of each button to change the Y offset of the image (to display a different state).
      Inside my control callback, I can Console.print the value of "group" via component.get("group") and it will display correctly.
      but when I try to use component.set("group", 2(or whatever)), i get an error that the property was not found.
      can somebody help me out?
      cheers!

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

        @prehm said in noob question: UI component.set():

        i edited the JSON objects in the component list to have an extra property called "group",

        This won't work unfortunately, you can't add new properties to components, only edit existing ones. The fact that get is returning the value you've added to the JSON is a quirk.

        Why are you using LAF to apply an image to a button? Buttons already have an image property that handles the offset for different button states.

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

        1 Reply Last reply Reply Quote 0
        • P
          prehm
          last edited by prehm

          ah I see, thats unfortunate.
          my buttons have four different states, and should go to the next one on each click.
          as far as i understood the stock buttons only support states for on/off/hover states, that why i went for look and feel, and because i might want to experiment with blend modes later on, which (i think) are not available outside look and feel (?)

          i now used the text property and parseInt to set my value, which doesnt feel clean but works.
          is there maybe a list somewhere of the properties that can be used in a UI json object? i looked in hise.docs but didn't find anything.

          cheers!

          d.healeyD HISEnbergH 2 Replies Last reply Reply Quote 0
          • d.healeyD
            d.healey @prehm
            last edited by

            @prehm For a multi-state button a better choice is probably to use a panel, and you can set its value from 0-3. with each click and use mod (%) to loop back round to zero.

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

            1 Reply Last reply Reply Quote 0
            • HISEnbergH
              HISEnberg @prehm
              last edited by

              @prehm This will be useful for you:

              Link Preview Image
              HISE | Docs

              favicon

              (docs.hise.dev)

              P 1 Reply Last reply Reply Quote 0
              • P
                prehm @HISEnberg
                last edited by

                @HISEnberg
                oh very cool thanks!
                so if i understand correctly, using obj.data allows me to define control data that couldn't be set using the UI json object? or is the data object also limited to specific properties?

                HISEnbergH 1 Reply Last reply Reply Quote 0
                • HISEnbergH
                  HISEnberg @prehm
                  last edited by

                  @prehm there's been a few posts floating around on the topic of panels lately. Hypothetically the panel can store both UI and control data. In practice, for control data, it is best to use another component and reflect UI changes in the panel. So in your case, maybe try using a hidden knob for your four-button state, and using mousecallbacks and a paint routine on the panel to interact with and change the state of the knob.

                  You could bypass the knob altogether, I sometimes find issues with it when trying load presets or initialize the project. Really depends on what you are trying to do though.

                  Link Preview Image
                  saveInPreset not working for panel data?

                  @VirtualVirgin You could do it like this which might make it seem like it makes more sense const panelObj = Panel1.getValue(); Console.print(panelObj.test1);

                  favicon

                  Forum (forum.hise.audio)

                  Link Preview Image
                  Is panel.data persistent?

                  I thought it was, but this snippet seems to show otherwise. HiseSnippet 984.3ocsVstaaaCElxwpq1asXEnO.B5WJaFAVdtNdscXcwIY0aKIF0YA6eELTGGSDIRAR5rYTzm08Jr2fsC0k...

                  favicon

                  Forum (forum.hise.audio)

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

                  46

                  Online

                  1.7k

                  Users

                  11.7k

                  Topics

                  101.9k

                  Posts