NSScrollView with magnification other than 1.0 causes NSFocusRing to be offset

585 Views Asked by At

I have an NSScrollView with a variety of sub view types. Some are NSTextViews, some are NSTextFields, some are NSButtons, etc.

When I set the magnification of my NSScrollView to anything other than 1.0, the focus ring is not drawn over the proper location of the view.

For example, this is what it should look like (scaled at 1.0):

Focus ring on <code>NSTextView</code> with <code>NSScrollView</code> at 1.0 magnification

But with a 1.5 magnification, this is what it looks like:

Focus ring on <code>NSTextView</code> with <code>NSScrollView</code> at 1.0 magnification

Please note that on Stack Overflow, the images look about the same size, but in the actual screenshot, the 1.5 scaled image is larger. But you get the idea with the focus ring being offset.

To set the magnification, I am using the following code:

[self.scrollView setMagnification:zoomLevel]

So it's pretty simple code. The NSTextView obviously has its own NSScrollView surrounding it and that's actually where the focus ring is being draw of course. The same problem exists with just regular NSTextFields and NSButtons as you can see in these screenshots:

NSTextField with focus ring and NSScrollView magnification at 1.5

NSButton with focus ring and NSScrollView magnification at 1.5

You can see the button's focus ring is just a blue dot offset from where it should be.

At 1.0 magnification, it all looks normal.

If I use pinch to zoom, you can see the focus ring moving away from the field as the scrollview is zoomed.

Does anyone know what the proper way to use the setMagnification method of an NSScrollView should be? It seems like I should be able to just set the value. That does work, but I have these troubles with the focus rings not lining up.

Any help or ideas would be greatly appreciated.

This is on Mac OS X 10.10.1, but it also happens on OS X 10.9.x. and also happened on OS X 10.10.

0

There are 0 best solutions below