HISE Logo Forum
    • Categories
    • Register
    • Login

    the createHeadSprite script reveals some problems with GUI scripting

    Scheduled Pinned Locked Moved Scripting
    17 Posts 3 Posters 3.0k 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.
    • E
      elanhickler
      last edited by

      How do I make the continuous knob midi learnable?

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

        Just set the "enableMidiLearn" property to true :)

        1 Reply Last reply Reply Quote 0
        • E
          elanhickler
          last edited by elanhickler

          How would I take that continous knob script and make that default true until someone adds enableMidiLearn as false?

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

            inline function createHeadSprite(name, x, y)
            {
                local widget = Content.addPanel(name, x, y);
            
                Content.setPropertiesFromJSON(name, {
                  "width": 200,
                  "height": 200,
                  "enableMidiLearn": true, // <<== The magic happens here...
                  "saveInPreset": true,
                  "allowCallbacks": "Clicks, Hover & Dragging"
                });
            
            
            [...]
            

            or in your version:

            inline function addContinuousKnob(name, x, y, json)
            {
                local widget = Content.addPanel(name, x, y);
            
                Content.setPropertiesFromJSON(name, json);
            `
                widget.set("enableMidiLearn", true); // important to do this after the JSON restoring...
            
            [...]
            
            1 Reply Last reply Reply Quote 0
            • E
              elanhickler
              last edited by elanhickler

              waaaat, why wouldn't that override the json? by doing widget.set("enableMidiLearn", true); after Content.setPropertiesFromJSON(name, json);

              1 Reply Last reply Reply Quote 0
              • E
                elanhickler
                last edited by elanhickler

                Oh, it looks like we need Content.addPropertiesFromJSON(name, json); otherwise you can't do default values. ADD rather than SET/overwrite

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

                  IIRC setPropertiesFromJSON() already just overwrites the properties that are passed in.

                  1 Reply Last reply Reply Quote 0
                  • E
                    elanhickler
                    last edited by elanhickler

                    That means I can't put a default value. Please consider my earlier suggestion. Content.addProperties

                    edit: or maybe there's a way to combine two jsons before going to setProperties?

                    1 Reply Last reply Reply Quote 0
                    • E
                      elanhickler
                      last edited by

                      Please tell me you are going to do something to allow default values. I don't have time to learn the C++ API right now and so I'd like to create a library of GUI widgets in javascript.

                      1 Reply Last reply Reply Quote 0
                      • E
                        elanhickler
                        last edited by elanhickler

                        Is there a way to combine JSONs?

                        Edit: No that wouldn't work, that would overwrite copy JSON properties unless something could be done about that to allow the 1st or last of the properties to be used.

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

                          I think the functionality is already there:

                          const var Button = Content.addButton("Button", 10, 10);
                          
                          Content.setPropertiesFromJSON("Button", {
                            "enabled": false	
                          });
                          
                          
                          Content.setPropertiesFromJSON("Button", {
                            "width": 160,
                            "height": 30
                          });
                          

                          This button will still be disabled because the second JSON doesn't overwrite the enabled property. This should allow you to set default values that won't be overwritten unless you explicitely add them in the JSON object.

                          1 Reply Last reply Reply Quote 0
                          • E
                            elanhickler
                            last edited by

                            ok great, works!

                            1 Reply Last reply Reply Quote 0
                            • E
                              elanhickler
                              last edited by elanhickler

                              I tried doing "enableMidiLearn": "true" (with and without quotes on true) in the json but it didn't allow the continuous knob to be midi learnable, maybe because I don't have a right click callback setup? I wouldn't know how to set that up for midi learn.

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

                              16

                              Online

                              1.7k

                              Users

                              11.9k

                              Topics

                              103.3k

                              Posts