Skip to main content
Participant
November 5, 2022
Answered

PutFileDialog immediately returns kCanceledErr on mac

  • November 5, 2022
  • 1 reply
  • 240 views

hi everyone, 

 

I'm encountering an issue very similar to this old post:

https://community.adobe.com/t5/illustrator-discussions/problem-in-putfiledialog-and-getfiledialog/m-p/9499743#M73926

 

AIUserSuite::PutFileDialog() works great on windows, but on mac it returns kCanceledErr immediately without waiting for user input. The code snippet below is called inside a 

csxs event callback.

 

	AppContext appContext(gPlugin->GetPluginRef());
	ai::FilePath ioFilePath;
	AIFileDialogFilters dlgOpts;
	dlgOpts.AddFilter(ai::UnicodeString("TIFF (*.tif)"), ai::UnicodeString("*.tif"));
	const ai::UnicodeString title( "Where do you want to save the exported file?" );
	ai::UnicodeString defaultName;
	const AIErr err = sAIUser->PutFileDialog( title, &dlgOpts, defaultName, ioFilePath );

 

Any insights would be greatly appreciated. 

 

Thanks much in advance,

 

David

This topic has been closed for replies.
Correct answer IT2496043225lj

I figured this out - replying to my own question in case it helps anyone.

 

Turns out this has to do with (undocumented?) interaction between CEP and AIP. 

In my particular case, the following sequence occurs:

  • User clicks 'export' button on the CEP modal.
  • The plugin dispatches 'export' event to AIP, then closes the CEP modal with CSInterface().closeExtension();
  • AIP receives the 'export' event and pops sAIUser->PutFileDialog() to prompt for file save location

What I found was that the CEP closeExtension() call causes Illustrator to issue an abortModal() or something similar on the AIP side, causing any modal opened there to immediately close (this happens with native swift modal window, such as NSSavePanel, as well). If I keep the CEP modal open, than the PutFileDialog stays open as well.

1 reply

IT2496043225ljAuthorCorrect answer
Participant
November 24, 2022

I figured this out - replying to my own question in case it helps anyone.

 

Turns out this has to do with (undocumented?) interaction between CEP and AIP. 

In my particular case, the following sequence occurs:

  • User clicks 'export' button on the CEP modal.
  • The plugin dispatches 'export' event to AIP, then closes the CEP modal with CSInterface().closeExtension();
  • AIP receives the 'export' event and pops sAIUser->PutFileDialog() to prompt for file save location

What I found was that the CEP closeExtension() call causes Illustrator to issue an abortModal() or something similar on the AIP side, causing any modal opened there to immediately close (this happens with native swift modal window, such as NSSavePanel, as well). If I keep the CEP modal open, than the PutFileDialog stays open as well.