开发者

NSTextView - drawing custom glyphs that can't be edited

I'm making an outliner using NSTextView. The outline: method on NSTextView doesn't quite capture what I need, so I've rolled my own using the typesetter/formatter. Now, I need to show the outline symbols next to each line fragment. How do you draw these symbols in such a way that the user cannot edit them? Any thoughts?

Thank you for your time!

EDIT

I don't want the cursor to be able to even cross the outline symbols (symbols like •, i, 1, etc). I'm thinking I will need 开发者_如何学Cto draw custom line fragments that can't be selected. Or perhaps overlay some other view that draws the symbols. I might even want symbols next to these outline symbols that can collapse outline elements. I'm looking more for architecture solutions than particular methods.


Use the NSTextView delegate method -textView:shouldChangeTextInRange:replacementString: and respond with NO for your uneditable range.

Update based on comments

Why not play with the margins of your text container, then use NSTextView's -drawViewBackgroundInRect: to draw the UI element in the margin?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜