JavaScript: how does findWidget work?

Hello,

I am completely new to JavaScript and currently trying to find my way around some basics.
Right now I am trying to access a widget from a function with findWidget(widgetId) and I can’t get it to work. Here is the script I’m using:

execute: function () {

    function testFunction(widget) {

        console.log("testFunctionActive");
        var checkBoxWidget = widget.findWidget("01").isChecked();
        console.log(checkBoxWidget);
        
    }



    studio.ui.showModalDialog({
        windowTitle: "Window Title",
        windowWidth: 340,
        windowHight: 120,
        widgetType: studio.ui.widgetType.Layout,
        layout: studio.ui.layoutType.VBoxLayout,
        items: [


            {
                widgetType: studio.ui.widgetType.CheckBox,
                widgetID: "01",
                text: "CheckBox",
                isChecked: false
                
            },

            {
                widgetType: studio.ui.widgetType.PushButton,
                widgetID: "pushButton",
                onClicked: function(){
                    testFunction(this);
                }
            }
            

        ]

    })


}

Can someone tell me what I’m missing here?

Thanks!
Katharina

Hi,

You were super close! The issue is your widgetID is using a capital D when it should be lower case: FMOD Studio | Scripting API Reference - widgetId.

When testing Studio scripts, I’d suggest having the Console window open:
image
On the Logging browser, showing Verbose Logging as it can identify issues while running scripts.

Hope this helps!

Well that is not embarassing at all :smile:
It is working now.

Thank you, Connor!

1 Like