Focus on Display Dialog on invokation

Hi guys,

I have an Applescript which displays a dialog with a text field in it. I invoke that script via a trigger in Quicksilver.

At the moment the invokation of the trigger does not put the dialog box (ant therefore the text field) in focus, so I have to click on the box to activate it before I can type something. Is there a way to remedy the situatioin?

This is my display dialog line so far:


display dialog "Enter message:" default answer "" buttons {"Cancel", "Ok"} default button "Ok"

Many thanks in advance!

Nickolay

What is “the invocation of the trigger”?

gl,

A trigger is a key combination defined in Quicksilver, which is set to run a program, an applescript, perform a network location change and so on.

By “invokation of a trigger” I mean the pressing of this key combination.

More on trigger can be found here: http://docs.blacktree.com/quicksilver/triggers

Try this:

activate
display dialog “Enter message:” default answer “” buttons {“Cancel”, “Ok”} default button “Ok”

gl,

Thanks kel, that works as needed.

However, after dismissing the dialog (with either OK or Cancel), the focus does not return to the previously active window. Any way to fix this?

Hi, Nickolay.

Although dialogs are part of the StandardAdditions, they’re displayed either by the application running the script or “ in a tell block “ by the addressed application. If possible, you need to get the currently frontmost application (if that’s the one responsible for the window) to display the dialog.

tell application (path to frontmost application as Unicode text)
	display dialog "Enter message:" default answer "" buttons {"Cancel", "Ok"} default button "Ok"
end tell

Thank you Nigel. Just waht I wanted to achieve.

Cheers,
Nickolay