nsscrollview

How to maintain the scroll position in NSScrollView when changing scale?

独自空忆成欢 提交于 2019-11-28 21:28:25
问题 I've got an NSView (myView) wrapped in an NSScrollView (myScrollView). Using zoom-in/out buttons, the user can alter the scale of myView. If the user is currently scrolled to a particular spot in myView, I'd like to keep that part of the view on-screen after the zooming has taken place. I've got code that looks like this: // preserve current position in scrollview NSRect oldVisibleRect = [[myScrollView contentView] documentVisibleRect]; NSPoint oldCenter = NSPointFromCGPoint(CGPointMake

How to determine if a user has scrolled to the end of an NSTableView

让人想犯罪 __ 提交于 2019-11-28 20:56:28
I have an NSTableView, and I would like to know when the user has scrolled to the bottom, so I can perform an action. Not quite sure how to go about this? UPDATE: Here is how I am calculating the bottom of the table: -(void)tableViewDidScroll:(CPNotification) notification { var scrollView = [notification object]; var currentPosition = CGRectGetMaxY([scrollView visibleRect]); var tableViewHeight = [messagesTableView bounds].size.height - 100; //console.log("TableView Height: " + tableViewHeight); //console.log("Current Position: " + currentPosition); if (currentPosition > tableViewHeight - 100)

contentsize and contentOffset equivalent in NSScroll view

两盒软妹~` 提交于 2019-11-28 18:19:31
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. aepryus 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 scrollPoint:NSMakePoint(x,y)]; Edit: modernized the syntax In addition to the lines from @aepryus,

Callbacks When an NSScrollView is Scrolled?

与世无争的帅哥 提交于 2019-11-28 17:12:33
I'm making a Mac app which needs to know when the user is scrolling the NSScrollView , however, I can't find any methods like UIScrollView , which has the following delegate methods: – scrollViewDidScroll: – scrollViewWillBeginDragging: – scrollViewDidEndDragging:willDecelerate: – scrollViewShouldScrollToTop: – scrollViewDidScrollToTop: – scrollViewWillBeginDecelerating: – scrollViewDidEndDecelerating: Can I have the similar delegate methods for the App Kit? Thanks in advance. Kai. You can monitor a scroll view's changes by monitoring the bounds of it's content view. First set the content view

NSScrollView with auto layout not resizing until first manual window resize

浪尽此生 提交于 2019-11-28 12:43:06
I've got an OSX Cocoa app that has been built programatically (i.e., not with a NIB/XIB), which I'm trying to lay out using auto layout - but I'm getting some odd behaviour when the window first displays. My main content is an NSView that holds has a collection of 100 NSButtons as subviews, laid out vertically. The buttons are all constrained relative to the NSView and each other; both the NSView and all the NSButtons have translatesAutoresizingMaskIntoConstraints=NO set. I believe the code for the content view is good (i.e., no ambiguous layouts, etc), because if I set the main window's

Displaying text in a NSScrollView (Swift)

感情迁移 提交于 2019-11-28 11:27:00
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. I find that a bit confusing, since doing the exact same with a NSTextView instead works like a charm. What am I missing here? In the following example, I added the scrollView in the interface builder as my starting point. The following works if you your scrollView

Callbacks When an NSScrollView is Scrolled?

天涯浪子 提交于 2019-11-27 10:16:11
问题 I'm making a Mac app which needs to know when the user is scrolling the NSScrollView , however, I can't find any methods like UIScrollView , which has the following delegate methods: – scrollViewDidScroll: – scrollViewWillBeginDragging: – scrollViewDidEndDragging:willDecelerate: – scrollViewShouldScrollToTop: – scrollViewDidScrollToTop: – scrollViewWillBeginDecelerating: – scrollViewDidEndDecelerating: Can I have the similar delegate methods for the App Kit? Thanks in advance. Kai. 回答1: You

NSScrollView with auto layout not resizing until first manual window resize

有些话、适合烂在心里 提交于 2019-11-27 07:12:25
问题 I've got an OSX Cocoa app that has been built programatically (i.e., not with a NIB/XIB), which I'm trying to lay out using auto layout - but I'm getting some odd behaviour when the window first displays. My main content is an NSView that holds has a collection of 100 NSButtons as subviews, laid out vertically. The buttons are all constrained relative to the NSView and each other; both the NSView and all the NSButtons have translatesAutoresizingMaskIntoConstraints=NO set. I believe the code

iTunes Song Title Scrolling in Cocoa

拥有回忆 提交于 2019-11-27 01:14:04
I have searched extensively and cannot for the life of me find any information about how to achieve a similar effect to that of the iTunes song title scrolling if the text is too large in Cocoa. I have tried setting the bounds on a NSTextField to no avail. I have tried using NSTextView as well as various attempts at using NSScrollView. I am sure I am missing something simple but any help would be greatly appreciated. I am also hoping to not have to use CoreGraphics if at all possible. Example , notice the "Base.FM http://www ." text has been scrolled. If you need a better example open iTunes

iTunes Song Title Scrolling in Cocoa

守給你的承諾、 提交于 2019-11-26 09:35:44
问题 I have searched extensively and cannot for the life of me find any information about how to achieve a similar effect to that of the iTunes song title scrolling if the text is too large in Cocoa. I have tried setting the bounds on a NSTextField to no avail. I have tried using NSTextView as well as various attempts at using NSScrollView. I am sure I am missing something simple but any help would be greatly appreciated. I am also hoping to not have to use CoreGraphics if at all possible. Example