Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSScrollView in Cocoa

I am trying to get an NSSrollView with an NSTextField in it to work, however the scrollbars do not seem to respond to anything that I am coding.

I am declaring the NSScrollView as an IBOutlet, add it as a property and then synthesizing it. However, it's to no avail.

The scrollbars do appear when I resize, however they serve no function at the moment.

I have tried to use the apple documentation, but again, no joy there.

Any help? Thanks!

like image 657
Kevin Avatar asked Dec 09 '22 01:12

Kevin


1 Answers

As You was saying "For my purposes, any container which scrolls will do the trick" You can use NSTextView in an NSScrollView. And for setting text You need to use setString instead setStringValue.

Example how to set text in NSTextView:

.h

IBOutlet NSTextView *textView; 

.m

-(void)awakeFromNib {
    NSString *string = @"my text";
    [textView setString:string];
}


Don't forget IBOutlet NSTextView not NSScrollView.

NSTextView is in NSScrollView:

enter image description here

like image 105
Justin Boo Avatar answered Jan 01 '23 23:01

Justin Boo