Question

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 get that point?

Was it helpful?

Solution

The answer is [[myScrollView contentView] documentVisibleRect]

OTHER TIPS

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. :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top