Scrollbar for Popover Window

I made a popover window with the MBS example. This works fine. The text is selectable but not editable. Can I add a scrollbar to the NSTextFieldMBS?

Dim theTextField As New NSTextFieldMBS(kMargin, kMargin, kWidth, kHeight)
theTextField.StringValue = msg
theTextField.Editable = True
theTextField.focusRingType = 1
theTextField.Selectable = True

@Christian_Schmitz : any ideas for a scrollbar?

If you can get access to the popover’s NSView you might be able to add a NSScroller.

You can use a NSScrollViewMBS and put in a NSTextViewMBS as content.

Basically like this, but translated to Xojo:

	NSScrollView *s = [[NSScrollView alloc] init];
	NSSize contentSize = [s contentSize];
	[s setBorderType:NSNoBorder];
	[s setHasVerticalScroller:YES];
	[s setHasHorizontalScroller:NO];
	[s setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];

	NSTextView *v = [[NSTextView alloc] initWithFrame:NSMakeRect(0, 0, contentSize.width, contentSize.height)];
	[v setMinSize:NSMakeSize(0.0, contentSize.height)];
	[v setMaxSize:NSMakeSize(FLT_MAX, FLT_MAX)];
	[v setVerticallyResizable:YES];
	[v setHorizontallyResizable:NO];
	[v setAutoresizingMask:NSViewWidthSizable];
	[[v textContainer] setContainerSize:NSMakeSize(contentSize.width, FLT_MAX)];
	[[v textContainer] setWidthTracksTextView:YES];
	[s setDocumentView:v];
1 Like


Its based on Popover sample provided by Christian.
Check ContainerControl1… Open event for both NSTextViewControlMBS1 and TextArea1 (depending on what you prefer)

I hope it works


@Eduard_Schlecht :thanks, works fine.