First, a bit of background…
I’m trying to create a text field in the content region of a window. To try to keep it simple, I’m trying to create that field in response to the click of a button in a document-based AppleScript Studio project. That button was created in a window in Interface Builder. It appears properly and functions normally, and I have used it to successfully initiate other trial tasks, using its connection to the “on clicked” handler in the Document.applescript file.
Now, as to the problem I have…
I have tried several different scripts, all of which yield the same error. Here’s a typical scriptlet that characterizes my approach so far…
-- Since the initiating message comes from the button and the field is to be created in
-- the same window as the button, get a reference to the window that contains
-- the button that sent the message.
set theWindow to the window of theObject
-- Create the new text field and keep a reference to it.
set theNewField to make new text field at end of the text fields of theWindow with properties {bounds:{100, 100, 180, 132}}
-- Make sure the user can see the newly-created field.
update theWindow
There is already another text field in the window. I’m assuming that text field elements in a window are held in an array that is linked to the window object. I’m trying to add a text field object to that array, much like I might add a column to a data source object.
The error I get is, typically,
The error message sort of confirms that I’m trying to add to an array. The problem is that it appears that the array I’m trying to add it to is unmutable. That would say that I would need to do this with Cocoa code.
So… am I making this too complicated? What am I doing wrong?
Thanks very much for whatever you can recommend.
I’m using XCode 1.5, btw. Other system info follows…
Model: Powerbook G4 15" 1 GBy RAM
AppleScript: 1.9.3
Browser: Safari 125.12
Operating System: Mac OS X (10.3.7)