I tried to imitate the examples posted here but I still get an error.
on clicked theObject
set objectName to theObject's name as Unicode text
if objectName = "makeNewNote" then
set theNoteText to contents of text view "noteText" of scroll view "noteText" of panel "mainWindow"
I get an error:
Can’t make contents of «class texV» “noteText” of «class scrV» “noteText” of «class panN» “mainWindow” into type reference. (-1700)
Sorry, I know this is probably something very basic, but I’m missing it.
I see two possible problems with your code. First, although ‘panel’ is an object, you still need to reference it as a window. Second, when working with text views, you need to be careful about how you try to set it’s text. The ‘contents’ property of a text view actually returns a reference to the text view itself… not the text displayed in it. To get it’s actual displayed text, use the ‘content’ property instead. See apple’s text view doc for more info.
Assuming that you’ve correctly identified your objects, this line should actually look something like…
set theNoteText to content of text view "noteText" of scroll view "noteText" of window "mainWindow"
Also, unless you plan to use the clicked button’s name in your handler other than to detect which button was pressed, you can skip the unicode text coercion and just use…
on clicked theObject
if name of theObject is "BlahBlah" then...
Thank you everyone for your help. I got it working by changing it from “panel” to “window” and I took out the Unicode name change.
When I get some more time I’ll try out the differences between “content” and “contents” [although I think I understand since the linked reference said “content” is basically “contents of the contents”]