Re: Best way to orderly display dialogs etc.

Christopher Stone

On 10/31/2017, at 05:47, Jean-Christophe Helary <jean.christophe.helary@...> wrote:
I'm finding that depending on the tell block in which it is launched, a "display dialog" will request the user to turn to that app to be reacted too.

Hey Jean-Christophe,

Yes, and that's bad manners.

If you want your dialog to be in the Finder then the script should switch there before launching the dialog.

What is the best way to have "application neutral" dialogs that don't require moving back to the tell application ?

tell application (path to frontmost application as text)
display dialog "What's Up Doc?" buttons {"Cancel", "OK"} default button "OK" giving up after 20
end tell

I think Yvan mentioned a while ago that he used System Events to do that, but I'm not sure...

The problem with using System Events is that you'll leave the user high-and-dry in System Events.

They'll have to click-out of it or switch apps to get back to where they started.

I generally prefer the frontmost-app method above, because it'll drop you right back into the app where you started.

If I want an independent dialog I'll use my own applet.

There are times when I might elect to use System Events or FastScripts as the source app.  For instance — I might want to be able to interact with the Finder.  (When a choose from dialog is in a Finder tell block you're modally stuck in the dialog and can't utilize the Finder for drag and drop, etc.)

There's also an issue I'm forgetting with Default Folder and dialogs which may or may not still be relevant.

Best Regards,

Join to automatically receive all group messages.