Selected NSTableView Drag & Drop Rows Override Row Layout in Blue

I have an NSTableView that shows some images and text in each row. I have included multiple selection for NSTableView. And I included Drag & Drop for TableView to sort or export images. Now it happens that when I select multiple rows and drag them across the TableView, the entire row turns blue and remains blue (selected). Text and images are not visible. In Xcode, I get this message:

The layout still needs to be updated after the call - [NSTableRowView layout]. NSTableRowView or one of its superclasses can have an overridden -layout without calling super. Or something might have a dirty layout in the middle of an update. Both are programming errors in Cocoa Autolayout. The first may occur if some pre-Cocoa Autolayout class had a method called layout, but it needs to be fixed.

The problem exists only for multiple choice. When you enable single selection, it works great.

Here are three images to demonstrate the problem:

Figure 2: When dragged, it turns blue; overriding other layout components

http://ekiwi.de/temp/stackoverflow/original2.png

Figure 3: After dragging and dropping, it remains completely blue.

http://ekiwi.de/temp/stackoverflow/original3.png

So far, I have not found any solution or hint for two days. Maybe someone has a hint?

+7
xcode cocoa multiple-select selection nstableview
source share
1 answer

Finally, I was able to override the blue color of the selection by setting selectionHighlightStyle as a string. The following code in my subclass of NSTableRowView did the trick:

 - (NSTableViewSelectionHighlightStyle)selectionHighlightStyle { return NSTableViewSelectionHighlightStyleNone; } - (void)drawSelectionInRect:(NSRect)dirtyRect { [[NSColor redColor] set]; NSRectFill(dirtyRect); } 
+1
source share

All Articles