Text Field with connected Date Formatter: how to update with script

i have a text field (NSTextField) with an attached/connected date formatter (Date Formatter).

If i update the contents of the text field from the GUI the date formatter updates the text field to show it how i set it up to format

but how can i set the content of the text field with apple script and have the date formatter update the text

eg

set content of text field "blah" of window 1 to "1/2/3000"

then something to let the formatter know to update the display?

thanks
-nacho

Try this:

set value of text field "blah" of window 1 to "1/2/3000"

PreTech

That does not work either. I get this error:

Can’t make value of «class texF» "birthday" into type reference."

Nacho,

Are you working with AppleScript Studio or something else? Can we see more code? If you’re actually working with something else and gui scripting that, the text field and formatter might be part of a group or something. Try using a "get properties of text field “blah” and see if it returns anything. If it doesn’t then try to get every “UI element” of the window and “group” of the window and see if you can pinpoint whether the text field is actually part of something else.

PreTech

Yes I am working with apple script studio.

Right now all I have is a window with a text field with an attached date formatter and a button.

and an event handler on the button

when the user types something in the text field it gets correctly formatted to a date format

but what i want to do now
is using applescript

when the user clicks the button
in the code part, i set the content of the text field and it should follow the date formatter attached to teh text field

not sure what code to paste

Nacho,

This is a better subject for the AppleScript Studio forum. Having said that.

In Interface Builder, you have placed your button and marked it as clicked in the applescript menu under actions. Also the button needs a name in the applescript section. Then you click edit at the bottom of the inspector window. Xcode comes up with something like this:

on clicked theObject

end clicked

theObject is the the button. To refer to the text field you would then:

on clicked theObject
set contents of text field "blah" of window of theObject to "1/2/3000" 
end clicked

This code, however, will change what was typed in by the user. If you want a variable set to what the user typed in then:

on clicked theObject
set x to contents of text field "blah" of window of theObject
end clicked

PreTech