Copy link to clipboard
Copied
just realised that yes the OK button works on my win panel but no idea how to get the cancel button to function
Copy link to clipboard
Copied
Hi,
It is difficult to tell what excatly where you face issue. Could you please provide more information? If you tried via script, share you script to see what you have done till now.
Copy link to clipboard
Copied
Maybe you are looking for this
win.can.onClick = function ()
{
win.close ();
}
Copy link to clipboard
Copied
Maybe use in yout code something like it:
.add('button', undefined, 'Cancel', {name: 'cancel'})
Copy link to clipboard
Copied
I currently have the following code that creates both buttons, clicking on either causes the rest of the script to be run
win.grp2 = win.add('group');
win.select = win.grp2.add('button',undefined,'Ok');
win.can = win.grp2.add('button',undefined,'Cancel');
win.select.preferredSize = win.can.preferredSize=[70,20];
var myReturn = win.show();{
Copy link to clipboard
Copied
!(win.show() - 1)
Copy link to clipboard
Copied
Hi mikedpe
Well, I think you get the answer above. But here is the complete version grouped all together :-). In place of alert message, you can add your own processing. And your code shared above is not correct as win is undefined.
var win = new Window('dialog')
win.grp2 = win.add('group');
win.select = win.grp2.add('button', undefined, 'Ok');
win.can = win.grp2.add('button', undefined, 'Cancel');
win.select.preferredSize = win.can.preferredSize = [70, 20];
win.can.onClick = function () {
alert('Cancel Click')
win.close();
}
win.select.onClick = function () {
alert('OK Click')
win.close();
}
win.show();
Let us know if it resolves your query.
Copy link to clipboard
Copied
being honest I tried a few of the suggestions unsuccesfully and then thought I can do without a cancel button
Copy link to clipboard
Copied
Anyway my method works.
Copy link to clipboard
Copied
Your method always works 😊