Change Text Field's action behavior

I’ve got a text field that I have set up in IB for its text action to be “Sent on Enter Only”

but for a few conditions I’d like to change that property so that the user can hit enter to get a new line/paragraph in the text and write more without triggering an action.

I found this documentation which seems to describe what I want, in Objective-C methods.
http://developer.apple.com/mac/library/DOCUMENTATION/Cocoa/Conceptual/TextEditing/Tasks/FieldEditor.html

I think I want to implement

I have the text field linked as the sender in IB to this property

I’ve also bound its string value to

I’d like a handler that’s something like this:

As described in the link you provided.

Create a new Objective-C class file in your project and add the following code. In IB, set this class as the delegate of your text field.

Or you could convert this code to AppleScriptObjC, add the converted code to your appdelegate file and set it as the text field’s delegate. Either way will work.

UPDATE:
nevermind. I got it to work. THANKS.

I’ve got the new Obj-C class hooked up to my ASOC class via IB as

and then when I want to change the text field’s delegate to newLiner I use

I would create an instance variable in the new Objective-C class and set it to YES or NO depending on whether the field should have this functionality. Then in the method, I would check that value. If it was NO then I would return NO immediately.

You will probably want to get a book or two on Objective-C so all this makes more sense. I also have a video series on Objective-C and Xcode Essential Training at vtc.

In the .h file

in .m file

Put this as the first part in the method

Found a way to do this without needing an objective-c class.

I have a

, which I set to false on applicationLaunch. Then, in my ASOC code, when the conditions happen that I want the TextField to have the return create a new line instead of sending its contents I just set insertNL to true. This would also work with the tab key, changing “insertNewline” to “insertTab”