Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How to add onchange event trigger in dropdowns?

Explorer ,
Feb 17, 2023 Feb 17, 2023

Hi,

 

I try to add the onChange Event trigger in the font family dropdown. When changing the font family, load data to the font style dropdown based on the selections. I try multiple ways but had no luck. Please give your suggestions.

//get unique Array elements
Array.prototype.unique = function (){
    var r = new Array();
    o:for(var i = 0, n = this.length; i < n; i++){
        for(var x = 0, y = r.length; x < y; x++){
            if(r[x]==this[i]) continue o;}
        r[r.length] = this[i];}
    return r;
}
var sysFonts = app.fonts.everyItem();
sysFontsList = sysFonts.fontFamily.unique();
sysFontsList.unshift("- Select Font Family -");		

var myDialog = app.dialogs.add({name:"Font"});
with(myDialog){
	with(dialogColumns.add()){
		with(dialogRows.add()){
			with(dialogColumns.add()){
				with(borderPanels.add()){
					with(dialogColumns.add()){
						with(dialogRows.add()){
							with(dialogColumns.add()){
								staticTexts.add({staticLabel:"Font:", minWidth:40});
							}
							with(dialogColumns.add()){
								var dFontFamily = dropdowns.add({stringList:sysFontsList, selectedIndex:0});
							}
							with(dialogColumns.add()){
								staticTexts.add({staticLabel:"Font Style:", minWidth:45});
							}
							with(dialogColumns.add()){
								var dFontStyle = dropdowns.add();
							}
						}
					}
				}
			}
		}
	}
}
var myResult = myDialog.show();
	if(myResult == true){
		
	}

 

TOPICS
How to , Scripting , UXP Scripting
689
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 17, 2023 Feb 17, 2023

Hi,

 

Actually, I load the data in another dropdown based on the first dropdown dynamically.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Feb 17, 2023 Feb 17, 2023
LATEST

I don't think eventlisteners are set for the app.dialogs class and any of its properties. With dialogs, it"s all about building UI and use data once the dialog is closed.

For such events, you would like to use either ScriptUI in an extendscript script or html UI with UXP scripting:

https://developer.adobe.com/indesign/uxp/reference/uxp-scripting-samples/

HTH

Loic

 

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