changing color & adding text in a text view

Hi… I created a window in IB with a text view that I labeled “Texttest”

According to apple’s documentation, this should work:

tell text view "Texttest" of scroll view "Texttest" of window "main" set text color to {0, 65535, 0} end tell set contents of text view "Texttest" of scroll view "Texttest" of window "main" to "Hello this is a test"
yet I get an error every time… I actually can’t see anything about “scroll view” anywhere… so I never actually labelled scroll view… Is that my problem?

Or is there another problem?

Double click the text view. Thats the scroll view. Name it the same as the text view.

Ah thank you…

How can I set certain words to certain colors?

something in this vein will get you there:


set fontDone to {"Arial Black", 28}
set positionOfWord to 23
set excerciseTextView to text view 1 of scroll view 1 of window 1

		call method "setFont:" of (exerciseTextView's word positionOfWord) with parameter (call method "fontWithName:size:" of class "NSFont" with parameters fontDone)

also try content in place of contents
sometimes that “s” is the cause of on error (even if the documentation states to use it)

See also: Text View Suite

Thanks Bruce, I missed that part.
Appears to me that in an Xcode project we are calling sub-handlers from event handlers which places the sub “in the event handler”. I’ll keep that in mind.