nsscrollview

NSScrollView scrollToTop

拈花ヽ惹草 提交于 2019-12-21 12:13:51
问题 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))]; 回答1: Updated for Swift 5 : If your document view is flipped: scrollView.documentView?.scroll(.zero) otherwise: if let documentView = scrollView.documentView {

Scrolling in NSScrollView stops when overwriting scrollWheel function

天涯浪子 提交于 2019-12-20 03:12:30
问题 I experience a weird bug when I overwrite the scrollWheel(theEvent: NSEvent) function in a NSScrollView. Here's my code: import Cocoa class GraphScrollView: NSScrollView { var axisScrollViewInstance: AxisScrollView? override func scrollWheel(theEvent: NSEvent) { if theEvent.deltaY != 0 { axisScrollViewInstance?.scrollEventFromOtherScrollView(theEvent) super.scrollWheel(theEvent) } else if theEvent.deltaX != 0 { super.scrollWheel(theEvent) } } } class AxisScrollView: NSScrollView { var

NSScrollView inside another NSScrollView

本秂侑毒 提交于 2019-12-18 03:44:24
问题 I have a NSScrollview nested inside another NSScrollview . How do i make the inner view handle horizontal scrolling only? Vertical scrolling should move the outer view. Currently i pass the scrollWheel: event to the outer view from the inner view, but it is very slow. 回答1: I also had the problem of nested scroll views. The inner scroll view should scroll horizontally, and the outer should scroll vertically. When handling scroll events from magic mouse / trackpad, it is important to pick only

NSScrollView inside another NSScrollView

不想你离开。 提交于 2019-12-18 03:44:04
问题 I have a NSScrollview nested inside another NSScrollview . How do i make the inner view handle horizontal scrolling only? Vertical scrolling should move the outer view. Currently i pass the scrollWheel: event to the outer view from the inner view, but it is very slow. 回答1: I also had the problem of nested scroll views. The inner scroll view should scroll horizontally, and the outer should scroll vertically. When handling scroll events from magic mouse / trackpad, it is important to pick only

contentsize and contentOffset equivalent in NSScroll view

爱⌒轻易说出口 提交于 2019-12-17 22:34:18
问题 I am porting an app from Ipad to mac. (I know that it sounds weird) I stuck with NSScrollview. Please guide me contentsize , contentOffset equivalent in NSScrollview. 回答1: UIScrollView* uiScroll; uiScroll.contentSize; uiScroll.contentOffset; uiScroll.contentSize = CGSizeMake(w,h); uiScroll.contentOffset = CGPointMake(x,y); = NSScrollView* nsScroll; nsScroll.documentView.frame.size; nsScroll.documentVisibleRect.origin; nsScroll.documentView.frameSize = NSMakeSize(w,h); [nsScroll.documentView

Displaying text in a NSScrollView (Swift)

拈花ヽ惹草 提交于 2019-12-17 19:44:17
问题 Just started to learn Swift and created a little macOS app in which I want to use a NSScrollView to display an attributed String. I’ve tried: @IBOutlet var ScrollViewOutlet : NSScrollView var attributedString = NSMutableAttributedString(string: myText) ScrollViewOutlet.insertText(attributedString) But that doesn’t seem to work. Feels confusing since doing the exact same with a NSTextView instead works like a charm. What am I missing here? 回答1: In the following example, I added the scrollView

Fade out top and bottom of an NSScrollView

半世苍凉 提交于 2019-12-12 21:58:13
问题 Is there any way to make the top and bottom edges of an NSScrollView to fade to transparent? I've seen some code/answers that 'fades' it by adding a gradient of a certain color to the subview, basically, covering up the top and bottom with the background color. However, I would like it to actually fade to alpha=0, so you can actually see the contents of the view behind the scroll view. I'm planning my app to have various backgrounds behind this NSScrollView, and without any kind of transition

Getting NSWindow resizing right in an auto layout world

心不动则不痛 提交于 2019-12-12 09:03:16
问题 I'm having problem getting vertical window resizing working with an auto layout scroll view. What I Want I would like to replicate, as closely as possible, my app's current window resizing behaviour. The width of the window is flexible, but the height of the window should generally track the height of the contents. Specifically: Normally, the window automatically resizes its height to exactly match its contents (with the exception of #2). The user can choose to manually resize the window so

Soft scroll animation NSScrollView scrollToPoint:

爷,独闯天下 提交于 2019-12-12 08:23:22
问题 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 !!! 回答1: scrollToPoint is not animatable. Only animatable properties like bounds and

NSCollectionView loses scrollbars after changing minItemSize until view gets resized

醉酒当歌 提交于 2019-12-11 16:21:56
问题 I have an NSCollectionView with a vertical NSCollectionViewFlowLayout . I display rectangular icons in it. I also have a slider in the UI, and when that changes, I adjust the minItemSize , which I then use in collectionView:itemForRepresentedObjectAtIndexPath: to create an equally sized NSImageView to the returned NSCollectionViewItem 's imageView . Then I reload the view by invoking reloadData . After that, the view shows the icons in the new size as intended. The problem is, provided I have