Re: Add overflow indicator to text


Graham Cox
 



This is what we do in a drawing app, which works well for us. When the text box is selected, it shows the + symbol as part of the frame. If not selected that’s not visible, so the text itself isn’t modified by not fitting. If you have some sort of highlighting or frame around the text, something like this could work for you.

To detect whether this is drawn or not, we ask the layout manager of the text system for the -glyphRangeForTextContainer:, and compare it to the -glyphRangeForCharacterRange: for the entire text. The symbol is displayed when they are unequal. This is simple and reliable, though NSLayoutManagerDelegate has -layoutManager:didCompleteLayoutForTextContainer:atEnd: where the atEnd: part tells you whether it completed the job. 

—Graham



On 10 Nov 2017, at 4:41 am, Steve Mills <sjmills@...> wrote:

I'm using NSTextContainer with exclusionPaths, NSLayoutManager, and UITextView for rendering text into balloons, and the user can control the font size. When overflow occurs, I'd like to show an indicator. Just looking for thoughts on the best way to show that. My first thought is to insert a red ellipsis after that last visible character, although that could certainly cause it to re-wrap and overflow in a different spot. Other thoughts involve drawing something in a new layer at the overflow location, such as an ellipsis in a semi-transparent capsule shape.


Join cocoa@apple-dev.groups.io to automatically receive all group messages.