开发者

NSScrollView scroll position

I currently have a NSView in a NSScrollView. The NSView is large and I need to scroll to manage the object inside.

I want to draw a static rectangle in the center of the NSView without scrolling. I want to get the scrolling point (the NSClipPoint?) in the drawRect method of the NSView so that I can draw the rectangle at the last step of drawRect to make it on top.

I have looked through the doc and could only find methods to set the scroll point, not getting it. How can I 开发者_如何学JAVAget that point?


The answer is [[myScrollView contentView] documentVisibleRect]


I've never tried this, so I don't know if it will actually work or not (and I'm about 8 hours away from my Mac, so I can't give it a shot). But can you subclass the NSClipView that your NSScrollView is using and draw the rectangle in NSClipView's drawRect:? If that doesn't work, what about trying the same thing with the NSScrollView directly?

And if that doesn't work, er...report back and I'll remove this answer so as not to mislead anyone coming from Google. :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜