Why doesn't alignment stay the same? - Text field


I’ve build a AS application, where I load data from a .txt-file written by Python. The data I load will display in a text field using this apple script text.

-- Choose txt-file:
set txtFile to "/bridge/data_for_app_to_fetch/misc/current_date.txt"
set modules to load script (path to resource "modules.scpt" in directory "Scripts")
tell modules
	set dato to readTxtFileLines(txtFile)
end tell

-- Set contents of text fields and check buttons:
set textFields to {"cardAndPictureTextFieldEnterdate", "cardAndPictureTextFieldLastModified"}
repeat with x in textFields
	set content of text field x of windowReference to dato as text
end repeat

Where the ‘modules’ is an apple script file with a few functions that I use frequently containing for example the function ‘readTxtFileLines(txtFile)’. The idea is that on launch I run a Python file writing current date (‘dato’) into a text file that my app reads using apple script and then use the ‘set content of text field’ to display the current date in the UI of my app. The ‘windowReference’ is just a reference to ‘tab view item 1 of tab view “tabView” of window “mainWindow”’ - now all of this works perfect! But the strangest thing happens some times, and I can’t explain why. Here’s the deal:

The alignment of the text in the two text fields (‘cardAndPictureTextFieldEnterdate’ and ‘cardAndPictureTextFieldLastModified’) is predefined to be ‘right’ in the NIB-file with Interface Builder - nothing changed there. But after the ‘set content of text field x of (…)’-command the alignment of the text in text field “cardAndPictureTextFieldLastModified” goes to the left (?!). Any suggestions anyone?

Well… I thought that if I could only change the alignment of the content in the text field every time i do the ‘set content’-command to ‘right’ my problem would be solved regardless of what alignment apple script choose to display. But I can’t find any way to do that… Does anybody know how to change text alignment in a text field with apple script in apple script studio?


Model: MacBook 1. generation black
Browser: Firefox 3.5.2
Operating System: Mac OS X (10.4)