Question

I'm using the code http://jed-software.com/blog/?p=538 to allow user to select a folder under MAC OSX. It works fine if I place a button in the main form and click this button to open NSOpenPanel.

However, if I open a modal window with ShowModal, then, place a button in this modal window, click this button to open NSOpenPanel, after selected the folder in NSOpenPanel, no matter I click the OK or Cancel button, both NSOpenPanel and this modal window will be closed automatically.

I appreciate for any help to fix this problem.

Was it helpful?

Solution

If the ModalResult of a Button is not equal to mrNone and

If a form with ShowModal is opened,

 Form2.ShowModal;

Button1 on Form2

enter image description here

after the program code is executed in the event Button1Click(...) .

procedure TForm2.Button1Click(Sender: TObject);
begin
   OpenDialog1.Execute;
end;

When the OpenDialog1 is closed, Form2 is terminated immediately.
It does not matter whether to end OpenDialog1 with ok or cancel.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top