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?
kevin_g
(kevin g)
November 11, 2022, 8:14am
3
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
(https://www.dropbox.com/s/gxj3pdnteeyd0pg/Popover%20detachableWindowForPopover%20example.xojo_binary_project?dl=1 )
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
2 Likes
@Eduard_Schlecht :thanks, works fine.