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");
}
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
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
Copy link to clipboard
Copied
Thanks a lot friend , you saved me 🙂