Programmatically change name/label of "static_text" field in dialog

Explorer ,
Jan 30, 2018

Copy link to clipboard

Copied

Is this possible or no?

Adobe Community Professional
Correct answer by Thom Parker | Adobe Community Professional

I think he means in a dialog object

And yes you can, just use the dialog.load function. Same as it's used in the "initialize" function

TOPICS
Acrobat SDK and JavaScript, Macintosh, Windows

Views

208

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Programmatically change name/label of "static_text" field in dialog

Explorer ,
Jan 30, 2018

Copy link to clipboard

Copied

Is this possible or no?

Adobe Community Professional
Correct answer by Thom Parker | Adobe Community Professional

I think he means in a dialog object

And yes you can, just use the dialog.load function. Same as it's used in the "initialize" function

TOPICS
Acrobat SDK and JavaScript, Macintosh, Windows

Views

209

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jan 30, 2018 0
Adobe Community Professional ,
Jan 30, 2018

Copy link to clipboard

Copied

You can't use Acrobat JavaScript to change the name of a field. However, you can collect up all the properties of a field, delete it, create a new field with the name you want and apply the properties of the old field to the new field.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 30, 2018 0
Adobe Community Professional ,
Jan 30, 2018

Copy link to clipboard

Copied

I think he means in a dialog object

And yes you can, just use the dialog.load function. Same as it's used in the "initialize" function

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 30, 2018 2
Most Valuable Participant ,
Jan 30, 2018

Copy link to clipboard

Copied

Are you sure about that? The name property of a static_text component can be changed in the initialize event?

I just tried it and it didn't work...

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 30, 2018 0
Explorer ,
Jan 31, 2018

Copy link to clipboard

Copied

Awesome. That worked for me:

dialog.load({ "myid": "Some New Caption" });

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 31, 2018 0
Most Valuable Participant ,
Jan 31, 2018

Copy link to clipboard

Copied

Not working for me... Can someone point out what's wrong with this code?

var dialog1 = {

    initialize: function (dialog) {

        dialog.load ({"lbl1": "Caption:"});

    },

    cancel: function(dialog) {

        return;

    },

    destroy: function(dialog) {

        return;

    },

    commit:function (dialog) {

        return;

    },

    validate:function (dialog) {

        return true;

          

    },

    description: {

        name: "Test Dialog",

        align_children: "align_left",

        width: 350,

        height: 100,

        elements:[

            {

                type: "cluster",

                name: "",

                align_children: "align_left",

                elements:[

                {

                    type: "view",

                    align_children: "align_distribute",

                    elements:[

                        {

                            item_id: "lbl1",

                            type: "static_text",

                        },

                        {

                            item_id: "txt1",

                            type: "edit_text",

                            width: 200,

                            height: 25

                        }

                    ]

                },

                {

                    alignment: "align_right",

                    type: "ok_cancel",

                    ok_name: "OK",

                    cancel_name: "Cancel"

                },

              

                ]

            },

          

        ]

    }

};

app.execDialog(dialog1)

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 31, 2018 0
Explorer ,
Jan 31, 2018

Copy link to clipboard

Copied

It seems the size of the field doesn't dynamically change when you change the caption. So since you don't specify the "name" property in the element definition, it's probably sizing the field with a very small width which is probably why you can't see the caption. Try specifying a name up front. In my case, I'm lucky because the two captions I'm toggling between are very similar in character length.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 31, 2018 0
Explorer ,
Jan 31, 2018

Copy link to clipboard

Copied

So just make sure you set the initial name to the longest possible value.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 31, 2018 0
Most Valuable Participant ,
Jan 31, 2018

Copy link to clipboard

Copied

Actually, that's not necessary, but your reply did bring me to the right solution. I was missing the width setting for the field, and since its original value is empty, it probably defaults to 0. So all you need to do is set it in the description and then it works. Neat!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 31, 2018 0
Explorer ,
Jan 31, 2018

Copy link to clipboard

Copied

Ah right, you can either specify a name up front and it will automatically determine the width based on that or just specify the width like you did. I don't have width set on mine.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 31, 2018 0
Adobe Community Professional ,
Jan 31, 2018

Copy link to clipboard

Copied

Correct!  Many of the fields have default sizes and many do not. This mostly this lack of sizing applies to the width. So something has to be in there to give it the initial size. An alternative is to set the alignment to "align_fill". This expands the field to the width of it's container. So of course the container has to have a size as well. I usually set it's alignment to "align_fill" as well, and so on up the tree.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 31, 2018 0