Question

I'm trying to figure out how the content magnification of NSScrollView works:

I have a NSScrollView, in which I'm trying to add a NSView which contains a NSTextField.

I create the NSView with the text field and add it to the NSScrollView document view (scrollView.documentView addSubview:...), so I end up with the following:

NSScrollView.documentView -> NSView -> NSTextField

When the magnification changes on the NSScrollView, the NSView is automatically resized, and the bounds / clicking area of the NSTextField are also resized, but the actual NSTextField doesn't resize: (those red outlines are the are where the cursor will change if I mouse over / where I have to click to start editing, so that is actually scaling properly somehow)

normal size zoomed in, mouse over / start edit bounds in red even more zoomed in, again the actual bounds are somehow scaling so I have to click within those red dots to start editing

If I skip the NSView, and add the NSTextField directly to the NSSCrollView.documentView, I get a similar "effect" where the actual text / textfield will scale, but not the focus ring:

now the textfield is ok, but the focus ring does not scale

It looks like whatever is directly "below" the NSScrollView.documentView will scale properly, but not its subviews?

I tried setting autoresizing masks and autoresizessubviews->TRUE everywhere but to no avail...

What am I doing wrong?

Thanks for the help!

Was it helpful?

Solution

I don't think you're doing anything wrong, it's just broken. Most widgets are not going to scale up and down in a sane way, sadly. They're very old classes and have tons of hacks in them, and scaling was just (re-)added recently.

Zooming is great if you're implementing your own view, but isn't going to be very useful for widgets. (I don't even know if they have fully scalable art for all widgets.)

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