NSTextViewでのワードラップとか

NSTextViewの表示範囲の端にきても自動改行しないようにするには、/Developer/Examples/AppKit/TextSizingExampleのReadmeを参考にNSTextViewとNSTextContainerのパラメータを設定する。NSScrollViewに横スクロールバーを表示するよう設定するのを忘れずに。

で、改行する場合に単語単位で改行するか文字単位で改行するかを設定するには、NSMutableParagraphStyleのsetLineBreakMode:を使って設定して、NSTextViewにsetDefaultParagraphStyle:で適用すればいい。

TextSizingExampleでは動的に表示するNSTextViewを切り替えているようだけど、実際には動的にパラメータを設定しなおすだけでも問題ないっぽい。大量にNSTextViewを保持するのはイヤだ。


Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <img localsrc="" alt="">