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

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -