Page 1 of 1

suggestion handling custom 'save as' in actions framework

Posted: Mon Feb 18, 2008 8:52 pm
by toolwiz
In the actions demo where you add the code to handle saving custom file formats, there's a flag called "success". If it's false, it displays a warning box.

This needs to be a three-valued flag, not a simple true/false flag, because if you hit the Cancel button on the Save dialog, it's neither a success nor a failure. There needs to be a way to return a value like "canceled" or "ignore" or something like that because internally I think that a return of "success=true" does certain things (like resets the flag that says the file has been saved?) while a return of "success=false" doesn't -- but the false value also displays that warning box, which is just not appropriate if you hit the Cancel button. Neither is it appropriate to say "success=true".

-David

Posted: Tue Feb 19, 2008 9:44 am
by Sergey Tkachenko
Do you mean that the program will ask additional questions to the user before saving, and the user can cancel saving while answering?
In this case, of cause, reading must report failure to the program, but displaying an error message with the list of possible reasons of error is wrong.

Well, for compatibility reasons I do not want to add new parameters to events. Instead, I'll add a new property to TrvActionSave: SuppressNextErrorMessage: Boolean.
In TrvActionSave.OnCustomFileOperation, you can set this property to True, and error message will not be displayed. After that, this property will be reset to False again.