nsscrollview

Growing NSTextView to fit contents is clipping last line of text

孤街醉人 提交于 2019-12-04 07:21:17
I'm trying to create an NSTextView that grows vertically as the user types and scrolls once the height has reached a maximum. This is similar to the text view in Messages works. My first attempt uses the delegate to listen for text changes and adjust the height constraint associated with the NSTextView's scroll view: - (void)textDidChange:(NSNotification *)notification { NSTextView *textView = self.textView; NSRect usedRect = [textView.textContainer.layoutManager usedRectForTextContainer:textView.textContainer]; NSLog(@"DEBUG: used rect: %@", NSStringFromRect(usedRect)); self

NSScrollView scrollToTop

只谈情不闲聊 提交于 2019-12-04 05:54:22
Does anyone know the correct way to scroll the NSScrollView to the top? I was looking for an equivalent to the UIView's scrollToTop method. This is what I have so far, but its not quite right under all situations [self.contentView scrollToPoint:NSMakePoint(0, MAX(contentView.frameHeight, ((NSView*)self.documentView).frameHeight))]; Updated for Swift 5 : If your document view is flipped: scrollView.documentView?.scroll(.zero) otherwise: if let documentView = scrollView.documentView { documentView.scroll(NSPoint(x: 0, y: documentView.bounds.size.height)) } Finally figured it out. Works like a

How to pass scroll events to parent NSScrollView

a 夏天 提交于 2019-12-04 05:09:48
I need fixed-size NSTextViews inside a larger scrolling window. IB requires that the textviews be inside their own NSScrollViews, even though their min/max sizes are fixed so that they won’t actually scroll. When trackpad gestures are made within the textview frames (regardless of whether they have focus), they are captured by the textviews’ scrollviews, so nothing happens. How do I tell the textviews’ scrollviews to pass scroll events up to the window’s main scrollview? (Or perhaps I should be asking how I tell the window’s main scrollview to handle these events itself and not pass them on to

Rounded corners on NSTableView

回眸只為那壹抹淺笑 提交于 2019-12-04 02:04:17
问题 I have a custom view subclass similar to NSBox that draws a rounded box background. The problem is that if I place a view like an NSTableView in the box view, it does not clip to the rounded corners. Is there any way to round the corners of NSTableView and its parent scroll view? 回答1: I haven't tried this with a table view but have with other controls. In a subclass of NSTableView (or whatever view/control you want to clip) Override drawRect: Create an NSBezierPath with the shape you want

Soft scroll animation NSScrollView scrollToPoint:

坚强是说给别人听的谎言 提交于 2019-12-04 01:04:23
I want to create soft animation between transitions in simply UI: view that moved When a call scrollToPoint: for move view to point that transition doesn't animate. I'm newbe in Cocoa programming (iOS is my background). And I don't know how right use .animator or NSAnimationContext. Also I was read Core Animation guide but didn't find the solution. The source can be reach on Git Hub repository Please help !!! scrollToPoint is not animatable. Only animatable properties like bounds and position in NSAnimatablePropertyContainer are animated. You don't need to do anything with CALayer: remove the

Hide scrollers while leaving scrolling itself enabled in NSScrollView

荒凉一梦 提交于 2019-12-04 00:34:06
问题 I'd like to hide the NSScroller s of NSScrollView . I'm aware of the methods setHasHorizontalScroller: and setHasVerticalScroller: . However, if I disable the scrollers, scrolling in that direction gets disabled as well. I'd like to only hide the scrollers while maintaining the possibility to scroll. Any thoughts on this? 回答1: I was able to do this by doing: [labelsScrollView setHasHorizontalScroller:YES]; [[labelsScrollView horizontalScroller] setAlphaValue:0]; 回答2: The trick of setting

How do you get NSScrollView to center the document view in 10.9 and later?

[亡魂溺海] 提交于 2019-12-03 18:30:24
问题 There are lots of examples out there of how to get NSScrollView to center its document view. Here are two examples (which are so similar that somebody is copying somebody without attribution, but the point of how is there.) http://www.bergdesign.com/developer/index_files/88a764e343ce7190c4372d1425b3b6a3-0.html https://github.com/devosoft/avida/blob/master/apps/viewer-macos/src/main/CenteringClipView.h This is normally done by subclassing NSClipView and overriding: - (NSPoint

Get height of content in NSTableView

左心房为你撑大大i 提交于 2019-12-03 15:58:55
Is there a way to get the height of the content in an NSTableView . In iOS, you can use the -contentSize method of UIScrollView . However, the -contentSize method of NSScrollView seems to just return the height of only the visible section of the NSScrollView , not including whatever is offscreen. So, how can this be done on a Mac? - (NSSize)contentSize in Appkit returns the size of the NSClipView , and not the height of the content that scrolls inside the table view. I don't know how UIScrollView s work, but on OS X, an NSScrollView has a "content view" (more aptly named the NSClipView ) that

Scroller background not transparent in NSScrollView

余生颓废 提交于 2019-12-03 14:44:41
Hi! I am using an NSScrollView which has a view-based NSTableView. Whenever the table adds a table cell the scrollers show up which is fine until you see that the scrollers don't have a transparent background. For some reason it's background is white as you can see on the image. I used IB to set up the NSScrollView and NSTableView and I cannot find any option where I can disable the scroller's background. Any ideas what may have cause this? Update: Settings for my NSScrollView in Xcode My only suggestion is to make sure that your NSScrollers are of the default style, or set to a class that

Overlay NSScroller over content

依然范特西╮ 提交于 2019-12-03 09:57:25
问题 Is there any way to overlay the NSScroller over the content of the scroll view (like in iOS)? I've already tried several approaches: a) setting the frame of the scroll view content view (NSClipView) to extend into the bounds of the scroller b) adding an NSScroller object as a subview of the scroll view (positioned where I want) c) creating an entirely custom scroller view and placing it as a subview (this worked, but that would mean that I need to rewrite all the functionality of NSScroller)