Skip to main content
Inspiring
September 1, 2025
Answered

How to change the order of pop-up control entries in a custom dialog?

  • September 1, 2025
  • 3 replies
  • 591 views

Hi,

I have integrated a pop-up control into a custom dialog. The entries that can be selected in the pop-up control are always listed in alphabetical order. How can I ensure that the preselected option always appears as the top/first entry in the pop-up control and that the other options always appear below the preselected entry?

 

 

    var layoutDialog = {
        cols: "2",
        rows: "5",
        druck: null,
        format: null,
        order: null,
        direction: null,

        initialize: function (dialog) {
            dialog.load({
                "col1": this.cols,
                "row1": this.rows,
                "druk": {
                    "Simplex": +1,
                    "Duplex": -2
                },
             });
        },
        DoDialog: function () {
            return app.execDialog(this);
        },
        description: {
            name: "Duplo Finisher: Change Page Order",
            elements: [{
                    type: "view",
                    align_children: "align_left",
                    elements: [{
                            type: "static_text",
                            name: "Reorder pages for Duplo finisher"
                        }, {
                            type: "cluster",
                            name: "Properties of the printed sheet",
                            elements: [{
                                    type: "view",
                                    align_children: "align_row",
                                    elements: [{
                                            type: "static_text",
                                            name: "columns:",
                                            char_width: 8
                                        }, {
                                            type: "edit_text",
                                            item_id: "col1",
                                            char_width: 5
                                        }
                                    ]
                                }, {
                                    type: "view",
                                    align_children: "align_row",
                                    elements: [{
                                            type: "static_text",
                                            name: "rows:",
                                            char_width: 8
                                        }, {
                                            type: "edit_text",
                                            item_id: "row1",
                                            char_width: 5
                                        }
                                    ]
                                }, {
                                    type: "view",
                                    align_children: "align_row",
                                    elements: [{
                                            type: "static_text",
                                            name: "print type:",
                                            char_width: 8
                                        }, {
                                            type: "popup", 
                                            item_id: "druk",
											width: 140,
											height: 22
                                        }
                                    ]
                                }
                            ]
                        }, {
                            alignment: "align_right",
                            type: "ok_cancel"
                        }                    ]
                }
            ]
        }
    };
	
	if (layoutDialog.DoDialog() === "ok") {

}
Correct answer bebarth

Hi,

You could modify a bit your script:

...
        initialize: function (dialog) {
            dialog.load({
                "col1": this.cols,
                "row1": this.rows,
             });
			dialog.load({"druk": {"Simplex": +1}});
			dialog.insertSeparatorEntryInList("druk");
			dialog.insertEntryInList({"druk": {"Duplex": -2}});
        },
...

@+

3 replies

bebarth
Community Expert
bebarthCommunity ExpertCorrect answer
Community Expert
September 11, 2025

Hi,

You could modify a bit your script:

...
        initialize: function (dialog) {
            dialog.load({
                "col1": this.cols,
                "row1": this.rows,
             });
			dialog.load({"druk": {"Simplex": +1}});
			dialog.insertSeparatorEntryInList("druk");
			dialog.insertEntryInList({"druk": {"Duplex": -2}});
        },
...

@+

yosimoAuthor
Inspiring
September 11, 2025

Well @bebarth, that's one solution. You marked it as the correct answer right awayWhether it's the right one remains to be seen.

 

@PDF Automation Station: I'm excited to see what you'll present.

 

Since I only ever have two entries in my popup controls, I use the Unicode character u+2063, the invisible separator. I place it before the entry that should not appear first in the popup control.

 

During my research, I came across this very old post where a user asks for a solution on how to display the names of the months in the correct order in a pop-up control.
Loading items in a dialog edit_text popUpEdit drop down list 

With the preceding Unicode character u+2063 (invisible separator), the list looks quite good in the popup control. I don't yet know whether this will be a hindrance to further use after selecting an entry.

dialog.load({"mth1":
{
"Jan":+1,
"\u2063Feb":-2,
"\u2063\u2063Mar":-3,
"\u2063\u2063\u2063Apr":-4,
"\u2063\u2063\u2063\u2063May":-5,
"\u2063\u2063\u2063\u2063\u2063Jun":-6,
"\u2063\u2063\u2063\u2063\u2063\u2063Jul":-7,
"\u2063\u2063\u2063\u2063\u2063\u2063\u2063Aug":-8,
"\u2063\u2063\u2063\u2063\u2063\u2063\u2063\u2063Sep":-9,
"\u2063\u2063\u2063\u2063\u2063\u2063\u2063\u2063\u2063Oct":-10,
"\u2063\u2063\u2063\u2063\u2063\u2063\u2063\u2063\u2063\u2063Nov":-11,
"\u2063\u2063\u2063\u2063\u2063\u2063\u2063\u2063\u2063\u2063\u2063Dec":-12
}
});

Regards

yosimo

PDF Automation Station
Community Expert
Community Expert
September 11, 2025

One of my solutions is the same as @bebarth 's.  dialog.insertSeparatorEntryInList( ) and dialog.insertEntryInList( ) are undocumented, but they work.  The other solution is to trigger the app.popUpMenu or app.popUpMenuEx method from a button and push the result into a readonly text field.  With these methods you can also set the order you want and you can use submenus as well.  Sorry to make you wait but the article was already queued up.

PDF Automation Station
Community Expert
Community Expert
September 2, 2025

You could capitalize the first letter of the preselected option and use lower case for the rest.

yosimoAuthor
Inspiring
September 3, 2025

Okay, thanks. Both work. But it doesn't look very nice.

I'll put the hairspace character \u200a in front of it. That looks best visually.

PDF Automation Station
Community Expert
Community Expert
September 9, 2025

I have two solutions for you.  One is exactly what you want.  They will be published here on Sep 13, 2025:

https://open.substack.com/pub/pdfautomationstation/p/popup-dialog-hacks-for-acrobat-pro

try67
Community Expert
Community Expert
September 1, 2025

Simplest solution is to add "1." and "2.", etc. before the item names.