NSTextField gets infinitely redrawn in NSTableView while editing

I have a subclassed NSTableView; with subclassed, editable NSTextFields.
Problem: When the user starts to edit them - so when they get the focus - they get redrawn infinitely.

Did anyone ever experienced similar? I could not find any relevant sources about this :(

But the issue is reproducible with the MacTables Xamarin sample project as well! In this project, there are only ~2 redraws/second; so this probably does not cause any visible problem. But still the issue is reproducable with MacTables. Which means it is reproducable with a normal, non-subclassed NSTableView; and with normal - subclassed, but only for observation - NSTextFields.

In my custom project, the redraw count per sec is much more; the whole app is quite useless due to it, it slows down everything so much.

Any workaround or typ is very much appreciated!

My observations:

  • If using an NSScrollView with NSTableView, layer backing will be activated on it by default. If I force it disabled via a custom NSScrollView descendant, where WantsLayer property's setter is cleared; this infinite redrawing issue disappears; but than the TableView will be much slower when scrolling.
  • I have experienced infinite redrawing issues earlier in custom NSTextField descendants (outside of NSTableView) as well. The problem seemed to be of another kind that time though. I had a custom cell, which mostly just centered vertically the text in the field; I've overridden some drawing methods without calling base in them. In the end, it turned out that DrawsBackground had to be true when the TextField got focused. That solved the problem then; but not this time
    ** Also tried to use this custom NSTextField descendant in the NSTableView, but the result is the same
  • Also tried to override NeedsDisplay, SetNeedsDisplay(...); and don't call base in them; or just with false. But the result is the same

Attached files:

  • MacTables.rar
    ** The forked sample project
  • gitdiff.txt
    ** What is forked in the above project. Showing that nothing is really touched
  • version.txt
    ** "About Xamarin Studio" provided information
  • Native StackTrace from DrawRect (MacTables).txt
  • Native StackTrace from DrawRect (custom project).txt

Answers

Sign In or Register to comment.