Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2010-08

tFileOpen Action, Is it possible to cancel the dialog...

4 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Wildfire

Just started messing about with the standard actions in Lazarus and came across a minor problem.

Is in possible to cancel the dialog in the BeforeExecute event, my plan was to ask the user to save the current file (Yes/No/Cancel) before opening another, problem is I don't know how to cancel the Dialog if the User selects Cancel.

My apologies if I'm missing something glaringly obvious but I've never used actions before and although I can work around it I was just hoping I could do it within the actions events themselves.

Reply by email

Alberto Narduzzi
to Wildfire
Is in possible to cancel the dialog in the BeforeExecute event, my plan was to ask the user to save the current file (Yes/No/Cancel) before opening another.

Cannot you check if the current file needs to be saved and prompt the user for it _before_ opening the dialog?

Cheers, A.

Reply by email

Wildfire
to Alberto Narduzzi
Cannot you check if the current file needs to be saved and prompt the user for it _before_ opening the dialog?

That's one work around, The FileOpen Action is tied to a couple of controls though (Menu, ToolButton) and I was hoping to do all the work inside (so the menu & toolbutton remain synchronised). It kind of defeats the purpose of the actions if I have to handle this myself.

If it can't be done I'll probably write my own action for opening the file but it seems to me that this is a very common situation so canceling the dialog within the BeforeExecute should be possible returning Cancel as the result.

I think I've just answered my own question, changing the dialogs execute event ???, is this the way to go or is their a simpler solution?

Reply by email

Alberto Narduzzi
to Wildfire
(...) The FileOpen Action is tied to a couple of controls though (Menu, ToolButton)

then handle it within the FileOpen Action. I guess there you have if(MyFileDialog.Execute) Then OpenTheFile(MyFileDialog.FileName), right?

So check for the file to be saved as first thing. At least, this is what my common sense tells me.

Cheers, A.

Reply by email