Return Focus to a text field??

Is there a command to focus on a text field. I’l like to have one text field be ready for text entry all the time, even after you’ve selected a different button. What’s the best way to do this? Thanks SO much for all the help. This site is awesome. :slight_smile:

-Evan

Basically, you’d do…

tell window "someWindow"
	set first responder to text field "someTextField"
end tell

If you’re going to be re-focusing it a lot, you might want to create a subroutine that would execute this action instead, so you could put a simple call anywhere in your code to invoke it…

on clicked theObject
	if name of theObject is "someButton" then
		--> Do some stuff?
		focusInputField()
	end if
end clicked

on launched theObject
	focusInputField()
end launched

on will open theObject
	if name of theObject is "MainWindow" then
		--> Do some stuff?
		focusInputField()
	end if
end will open

to focusInputField()
	tell window "someWindow"
		set first responder to text field "someTextField"
	end tell
end focusInputField

j

Will the first responder react, even if I’m just clicking a button on the same window? I have already set that text field to be the first responder, but once I click on a button on the same window, I’d like it to “pop” back to have the cursor in the text field. Will that do that? I’ll try it out. Thanks.

Worked great. I just stuck it in on idle routine. :slight_smile: