getSettingsWindowObject alternative



  • Apparently this command is deprecated, what should one use instead?


  • administrators

    Just use a JSON object that defines everything you need, like this one:

    namespace SettingsJson
    {
        const var isPlugin = Engine.isPlugin();
    
        // Use this function to get the Height for the popup
        inline function getHeight()
        {
            return isPlugin ? 360 : 520;
        };
        
        // Pass this object to the floating tile
        const var settings = {
        "Type": "Tabs",
        "Font": "Comic Sans MS",
        "FontSize": 18,
        "Dynamic": false,
        "ColourData":
            {
                "bgColour": "0",
                "itemColour1": "0xFF222222"
            },
        "Content": [
            {
            "Type": "CustomSettings",
            "Title": "Settings",
            "StyleData": {
            },
            "ColourData":
                {
                    "textColour": "0xFFCCCCCC"
                },
            "Font": "Comic Sans MS",
            "FontSize": 16,
            "Driver": !isPlugin,
            "Device": !isPlugin,
            "Output": !isPlugin,
            "BufferSize": !isPlugin,
            "SampleRate": !isPlugin,
            "GlobalBPM": true,
            "StreamingMode": false,
            "GraphicRendering": false,
            "ScaleFactor": true,
            "SustainCC": false,
            "ClearMidiCC": true,
            "SampleLocation": true,
            "DebugMode": true,
            "ScaleFactorList": [
                1,
                1.25,
                1.5,
                2
            ]
            }
            
        ],
        "CurrentTab": 0
        };
        
        
        if(!isPlugin)
        {
            settings["Content"].push(
            {
            "Type": "MidiSources",
            "Title": "MIDI Input",
            "StyleData": {
            },
            "Font": "Comic Sans MS",
            "FontSize": 15,
            "ColourData": {
                    "textColour": "0xFFCCCCCC"
            }
            });
        }
        
        settings["Content"].push({
            "Type": "MidiChannelList",
            "Title": "MIDI Channel Filter",
            "StyleData": {
            },
            "Font": "Comic Sans MS",
            "FontSize": 15,
            "ColourData": {
                    "textColour": "0xFFCCCCCC"
            }
            });
            
        settings["Content"].push({
        
            "Type": "MidiLearnPanel",
            "Title": "MIDI Automation",
            "Font": "Comic Sans MS",
            "FontSize": 15,
            "ColourData":
            {
                "textColour": "0xFFCCCCCC",
                "itemColour2": "0xFF50ebf8",
                "itemColour1": "0xFF111111",
                "bgColour": "0xFF000000"
            }
        });
    };
    

    As you can see, a few settings like sample rate etc. and even the whole MIDI sources panel are not relevant (or even harmful) for plugins and can be deactivated like shown above. This is much more flexible than relying on the old getSettingsWindowObject() function which I was constantly messing up.

    PS: The new MIDI learn panel is awesome :)



  • I'm trying to use this in the setPopupData() function of a panel but it's not working, can this only be used with a floating tile?



  • If I understand correctly this script is the replacement of the SettingsButton.js which used a FloatingTile for the last version of HISE on Github.

    So I think I can say that: YES Floating Tile, No the rest.

    Unless modification maybe ...


  • administrators

    This is explained at the front page of the FloatingTile API. Basically you need to set the callbackLevel in order to receive mouse events (event if you just want to open the Popup without doing any event scripting:

    Content.makeFrontInterface(600, 500);
    
    // The JSON data for a simple virtual Keyboard 
    const var data = {"Type": "Keyboard"};
    
    // Create a FloatingTile widget 
    const var FloatingTile = Content.addFloatingTile("FloatingTile", 0, 0);
    
    // Set its dimension to match the keyboard 
    FloatingTile.set("width", 200); FloatingTile.set("height", 72);
    
    // Pass the JSON data to the widget and it will show the keyboard.
    FloatingTile.setContentData(data);
    
    // Create a ScriptPanel 
    const var Panel = Content.addPanel("Panel", 230, 6);
    
    // Set the callback level to anything above No callbacks in order to receive mouse clicks
    Panel.set("allowCallbacks", "Context Menu");
    
    // Pass the JSON to the panel and it will open a popup when clicked // The second argument is the position and size of the popup: [x-pos, y-pos, width, height]
    Panel.setPopupData(data, [50, 50, 200, 72]);
    


  • Hmm, that's what I'm doing. I'll investigate further, I must have made a mistake somewhere



  • Yeah it was my mistake. I was putting the SettingsJson namespace after the setPopupData() but of course it needed to be declared before. Problem solved :)


Log in to reply

Looks like your connection to getSettingsWindowObject alternative was lost, please wait while we try to reconnect.