No internet connection
  1. Home
  2. How to

Create a Text Pop Up Box

By AK @DJAK
    2024-03-08 16:24:05.602Z

    Hi,

    I'm trying to create a Pop up Text box for various commands. One of them for instance is if I use this macro below to highlight the "Source Tempo" inside the "Elastic Properties" window where I can now enter the bpm. I would like for a Text Box to appear where I enter the value and it enters it in the "Source Tempo" field.

    I found this and tried to add it before or after and the Pop Up Box showed up but when I entered a value, it just closed and didn't put it into the "Source Tempo Field".

    var myVariable = prompt("Enter some text");
    

    Any help is greatly appreciated.

    Thanks

    • 5 replies
    1. Nathan Salefski @nathansalefski
        2024-03-08 20:54:46.876Z

        You can use this Display Dialog and then find the text field you'd like to edit and use something like textField.elementSetTextAreaValue({ value: tempo });

        let tempo = sf.interaction.displayDialog({
            prompt: "Tempo",
            defaultAnswer: "",
            buttons: ["Cancel", "OK"],
            defaultButton: "OK",
        }).text;
        
        1. DAK @DJAK
            2024-03-08 22:17:44.158Z

            Thank you for your help, @nathansalefski. However, I am still unable to understand the solution. I have copied and pasted the script that you shared and added it after the macro. Although the dialog box pops up, when I press "Enter", it closes without changing the value in the Source Tempo field.

            1. In reply tonathansalefski:
              DAK @DJAK
                2024-03-08 22:25:02.892Z

                I tried this as well...

                let tempo = sf.interaction.displayDialog({
                    prompt: "Tempo",
                    defaultAnswer: "",
                    buttons: ["Cancel", "OK"],
                    defaultButton: "OK",
                }).text;
                
                sf.ui.proTools.windows.whoseTitle.is("Elastic Properties").first.groups.whoseTitle.is(",j").first.textFields.whoseTitle.is("mSourceTempoField").elementSetTextAreaValue({ value: tempo });
                

                Sorry, I'm new to the javascript stuff

                1. Nathan Salefski @nathansalefski
                    2024-03-08 22:37:24.162Z

                    No worries. Certain text boxes require you to use your mouse and keyboard. Try this out:

                    let tempo = sf.interaction.displayDialog({
                        prompt: "Tempo",
                        defaultAnswer: "",
                        buttons: ["Cancel", "OK"],
                        defaultButton: "OK",
                    }).text;
                    
                    let elasticPropWin = sf.ui.proTools.windows.whoseTitle.is("Elastic Properties").first;
                    
                    elasticPropWin.groups.whoseTitle.is(",j").first.textFields.whoseTitle.is("mSourceTempoField").first.elementSetTextFieldWithAreaValue({
                        useMouseKeyboard: true,
                        value: tempo
                    });
                    
                    1. DAK @DJAK
                        2024-03-08 22:54:00.258Z

                        This was flawless! Thank you @nathansalefski.

                        In addition, I would like to request a feature that allows me to open the Elastic Properties window first and then close it after entering the Tempo. Also, I'm curious if there is a way to learn all the codes, names, functions, and other related information by myself. I would appreciate it if you could let me know.