Skip to main content
Inspiring
June 22, 2019
Answered

• DialogBox won't "close"… What could be the reason?

  • June 22, 2019
  • 1 reply
  • 2629 views

Hello -

I programmed a "dialog box"…

The "CANCEL" button works perfectly.

But the "OK" doesn't work as I wish.

In fact, it should:

  • Close/hide the dialog box.
  • And call the following function "commonCleaningArtworkPart_One_fct();";

With the below code, it doesn't close the dialog box at all but it run the script.

Now if I comment the line 20, well it close the dialog box (and of course it doesn't run the script, which is logic, since the function isn't called…)

Any idea why the dialog box doesn't close?

dialogBox_DC.onShow = function() {

dialogBox_DC.frameLocation = [dialogBox_X, dialogBox_Y];

dialogBox_DC.size = [dialogBox_Width, dialogBox_Height];

}

dialogBox_DC.btnPnl = dialogBox_DC.add('group', undefined, 'Do It!');

dialogBox_DC.btnPnl.orientation='row';

dialogBox_DC.btnPnl.buildBtn1 = dialogBox_DC.btnPnl.add('button',[15,15,115,35], 'Cancel', {name:'cancel'});

dialogBox_DC.btnPnl.buildBtn2 = dialogBox_DC.btnPnl.add('button', [125,15,225,35], 'OK', {name:'ok'});

dialogBox_DC.btnPnl.buildBtn1.onClick = scriptCanceled_fct();

dialogBox_DC.btnPnl.buildBtn2.onClick = function closeDialogBox_And_callTheCommonCleaningArtworkPartOneFunction_fct() {

dialogBox_DC.close();

app.redraw();

commonCleaningArtworkPart_One_fct();

}

dialogBox_DC.show();

//

// Translate dialog here =  Take the value of the selected pack type (from the dialog box)

//

var itis_a_TetraEdge1l =  dialogBox_DC.alertBtnsPnl1.selectEdge1l.value;

var itis_a_Crt4x125g =  dialogBox_DC.alertBtnsPnl1.selectCrt4x125g.value;

var itis_a_TetraPrisma =  dialogBox_DC.alertBtnsPnl1.selectPrisma.value;

Thank you,

- Dimitri

This topic has been closed for replies.
Correct answer Silly-V

I think your Ok button's onClick shouldn't have a function's name in it, I've never seen them written as such.

But it may work, still though, I think your best resource is Peter Kahrel guide.

I traditionally make UI windows close in this format:

// .... make window elements

var okButton = w.add("button", undefined "Ok");

okButton.onClick = function () {

// do any validation, allow to close when satisfied with user input...

w.close();

}

if (w.show() == 2) {

// user pressed Cancel

} else {

// user pressed Ok.

}

The returned 2 from the Window.show() call means they pressed "Cancel" and the other block is "Ok". The functions following the window closing are not being done inside the onClick handler, which could be an important difference in your case as the window is first closed yet there's a function happening inside a handler of an element of that same window.

1 reply

Silly-V
Silly-VCorrect answer
Legend
June 22, 2019

I think your Ok button's onClick shouldn't have a function's name in it, I've never seen them written as such.

But it may work, still though, I think your best resource is Peter Kahrel guide.

I traditionally make UI windows close in this format:

// .... make window elements

var okButton = w.add("button", undefined "Ok");

okButton.onClick = function () {

// do any validation, allow to close when satisfied with user input...

w.close();

}

if (w.show() == 2) {

// user pressed Cancel

} else {

// user pressed Ok.

}

The returned 2 from the Window.show() call means they pressed "Cancel" and the other block is "Ok". The functions following the window closing are not being done inside the onClick handler, which could be an important difference in your case as the window is first closed yet there's a function happening inside a handler of an element of that same window.

Inspiring
June 22, 2019

Hello Silly-V

SUPER cool…

Seems to work perfectly  :-)))))

Thank you sooooo much for your time and help on this.

regards,

- Dimitri