objective-ccocoaaddsubviewnsscrollviewnspredicateeditor

UI glitches when adding NSPredicateEditor to NSScrollView


I am trying to display an NSPredicateEditor within an NSScrollView so that users can make infinitely large queries with the editor. Everything is working more or less, but there are some strange UI glitches that are only occurring when the editor is nested in the scrollView, never when it isn't. Here is how I am setting up the editor in the scrollView:

predicateEditor = [[NSPredicateEditor alloc] init];
scrollView = [[NSScrollView alloc] initWithFrame:[[self view] frame]];
[scrollView setDocumentView:predicateEditor];
[scrollView setHasVerticalScroller:YES];
[scrollView setAutohidesScrollers:YES];

If I try and "break" it, by adding rows to the editor very quickly, the UI gets garbled like this:

enter image description here

But the problem is that if I don't nest the editor in a scrollView, it is impossible to have this error happen.

To reiterate, the only thing I am doing differently is nesting within an NSScrollView. Is there an issue with this I need to be aware of?

Thanks!


Solution

  • After testing out Roger's comment, I can verify that doing this in IB achieves the desired result. I don't know why it won't work very well programmatically, but oh well.