Selecting all the text in a textField

I thought I would pass this along so maybe someone else might find it and save more time than I just waisted.

I just wanted to get a TextField focus and have all of its text selected. This what I ended up with.


Script myAppDelegate¨¨

	 property property someTextField : missing value
¨¨
	 someActionLater_()¨
	 	 current application's NSTextField's selectText_ (someTextField)¨
	 end someOutletLater¨

end Script

Bind the someTextField to a textField in IB and everything will magically work.

Did you actually test this? This won’t “magically” work, in fact it won’t even compile. You have property twice in the property declaration line, and your action method needs “on” in front of it and either “sender” in the parentheses or no underscore, depending how you are going to call it. The method selectText_ is an instance method of the NSTextField class so it has to be addressed to an instance, not to the class. So, it should look like this:

property parent : class "NSObject"
	property someTextField : missing value
	
	on someActionLater_(sender)
		someTextField's selectText_(me)
	end someActionLater_

Ric