osx - Left indentation of the NSTextView -
i wrote following code:
nsmutableparagraphstyle *paragraphstyle; double indent = 100 * mm2pt / 10.0; if ( !m_textview ) return; if ( start == -1 && end == -1 ) { if( style.hasleftindent() ) { paragraphstyle = [[nsmutableparagraphstyle alloc] init]; [paragraphstyle setheadindent: indent]; [paragraphstyle setfirstlineheadindent: indent]; [m_textview setdefaultparagraphstyle:paragraphstyle]; [paragraphstyle release]; } } else // set attributes range. { nsrange range = nsmakerange(start, end-start); nstextstorage* storage = [m_textview textstorage]; if( style.hasleftindent() ) { paragraphstyle = [[nsmutableparagraphstyle alloc] init]; [paragraphstyle setfirstlineheadindent: indent]; [paragraphstyle setheadindent: indent]; [storage addattribute: nsparagraphstyleattributename value: paragraphstyle range: range]; [paragraphstyle release]; } }
the idea if start , end both equal -1, left indent should applied whole text view whether there text or not. , else condition should applied if have selection.
unfortunately code inside if not work, else condition works , can see text being indented selection.
what doing wrong? because if control empty (no text) , left indent applied text put in (programmatically or typing) should have left indentation. trying call code start = -1 , end = -1 existing text not change appearance.
thank you.
Comments
Post a Comment