Difference between revisions of "Cocoa Internals/Memo"

From Lazarus wiki
Jump to navigationJump to search
(Created page with "TMemo widgetset is implemented over NSTextView ==NSTextView== By default NSTextView is designed to be constantly word-wrapped. Disabling word-wrapping could be quite complic...")
 
m (Redirected page to Cocoa Internals/Text Controls)
Tag: New redirect
 
(11 intermediate revisions by the same user not shown)
Line 1: Line 1:
TMemo widgetset is implemented over NSTextView
+
#REDIRECT [[Cocoa Internals/Text Controls]]
 
 
==NSTextView==
 
By default NSTextView is designed to be constantly word-wrapped. Disabling word-wrapping could be quite complicated from a start due to odd-default values chosen by Apple, as well as complex (yet flexible) Text Layout system.
 
* NSTextView is a "cocoa" control, however it's not drawing the text by it's own it's also using:
 
* NSTextContainer. Both NSTextContainer and NSTextView settings influence on how the text is rendered in the end.
 
 
 
The example shows, of creating NSTextView that automatically resizes itself horizontally.
 
However NSTextView doesn't provide its own scrollbars, thus no scrollbars would be seen.
 
<source lang="delphi">
 
procedure TForm1.FormShow(Sender: TObject);
 
var
 
  txt : NSTextView;
 
begin
 
  txt := NSTextView.alloc.initWithFrame(NSMakeRect(10,ClientHeight-10-50,50,50));
 
 
 
  txt.setFont(NSFont.systemFontOfSize(NSFont.systemFontSizeForControlSize(NSRegularControlSize)));
 
 
 
  // making the maximum size - maximum!
 
  // 10000000 is a "magic constant" could be found in Apple documents
 
  txt.setMaxSize( NSMakeSize(10000000, 10000000));
 
  // preventing textContainer from following the width of NSTextView
 
  txt.textContainer.setWidthTracksTextView(false);
 
  // making TextContainer large enough.
 
  txt.textContainer.setContainerSize ( NSMakeSize( 10000000, 1024));
 
  // making NSTextView to resize automatically to the text boundries (max width)
 
  txt.setHorizontallyResizable(true);
 
 
 
  NSView(Self.Handle).addSubView(txt);
 
end;  </source>
 
==See Also==
 
*[[Cocoa Internals]]
 
[[Category:Cocoa]]
 

Latest revision as of 14:31, 13 June 2019