Auto resize text in NSTextView

Hi,

Is there any way to automatically resize the text in an NSTextView depending on the size of the text view and the amount of text in the text view?

Thanks in advance

Hi,

there is no direct way, you have to do it programmatically.
I don’t know, whether this is also possible in AppleScript Studio,
in ObjC you could use the windowDidResize: notification to calculate the size parameter, set the string attribute and redraw the text

Thanks Stefan :slight_smile:

Buzzing through the forums and decided I’d respond to this older post:

I haven’t tested it, but I think it might actually be possible. There is an event handler for NSTextView under View called “Bounds Changed.” If this is what I think it is, then something like this might work:

on bounds changed theObject
	if the name of theObject is "myNSTextField" then
		(* after getting your text field's width, do the following... *)
		set myFontSize to someCalculatedValueBasedOnWindowWidth
		set the font of the text view of scroll view "myNSTextField" of window "main" to call method "fontWithName:size:" of class "NSFont" with parameters {"Courier", myFontSize}
	end if
end bounds changed