onClick event not Working in SCRIPT UI

Engaged ,
Aug 02, 2020 Aug 02, 2020

Copy link to clipboard

Copied

Hi Pros.

Please Help me to fix the code, I Tried so many times but the code not working,, i dont know what i'm missing, here is the code, onClick Event not working :

 

//Building Interface Design
//Making Window
var myWindow= new Window ("dialog");
myWindow.text = "Break Linker";
myWindow.preferredSize.width = 200
myWindow.alignChildren = ["center","center"];  //"left";
myWindow.orientation ="column"; 
myWindow.spacing = 5; 
myWindow.margins = 15; 

//ButtonsPanel
var ButtonsPanel = myWindow.add("panel", undefined, undefined, {name: "panel2"});
ButtonsPanel.text = "Do Something";
ButtonsPanel.preferredSize.width = 450;
ButtonsPanel.orientation = "row";
ButtonsPanel.alignChildren = ["center","center"];
ButtonsPanel.spacing = 10;
ButtonsPanel.margins = 10;

var myButtonGroup = ButtonsPanel.add("group", undefined, {name: "myButtonGroup"});
myButtonGroup.preferredSize.width = 102;
myButtonGroup.orientation = "row";
myButtonGroup.alignChildren = ["center","center"];
myButtonGroup.spacing = 10;
myButtonGroup.margins = 0;

//Adding OK Button
var Button1 = myButtonGroup.add ("button", undefined, "OK");
var Button2 = myButtonGroup.add ("button", undefined, "Cancel");
var Button3 = myButtonGroup.add ("button", undefined, "About");

//Showing the Dialog -
var a = myWindow.show()

//What Happened if User Hit Cancel - 2 Refer to Button 2 and its Name is (Cancel)
if(a == 2){   
  alert("Canceled by User!");
  exit(0);
} 

//What Happened if User Hit About Button
Button3.onClick = function() {alertAbout();};
function alertAbout() {
alert("Break Linker - Version 2.00");
}

 

 

TOPICS
How to, Scripting

Views

181

Likes

translate

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
community guidelines

correct answers 1 Correct Answer

Adobe Community Professional , Aug 02, 2020 Aug 02, 2020
Move the following code, before the call of show method   //What Happened if User Hit About Button Button3.onClick = function() {alertAbout();}; function alertAbout() { alert("Break Linker - Version 2.00"); }   The reason the click handler is never called is because this code is never executed and hence the handler is never registered. The call to show method stops the execution of the code and awaits user input before the execution moves ahead. -Manan

Likes

translate

Translate

Translate
Adobe Community Professional ,
Aug 02, 2020 Aug 02, 2020

Copy link to clipboard

Copied

Move the following code, before the call of show method

 

//What Happened if User Hit About Button
Button3.onClick = function() {alertAbout();};
function alertAbout() {
alert("Break Linker - Version 2.00");
}

 

The reason the click handler is never called is because this code is never executed and hence the handler is never registered. The call to show method stops the execution of the code and awaits user input before the execution moves ahead.

-Manan

Likes

translate

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
community guidelines
Engaged ,
Aug 02, 2020 Aug 02, 2020

Copy link to clipboard

Copied

Thanks a lot friend , you saved me 🙂

Likes

translate

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
community guidelines