Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSTableView Drag&Drop selected rows overrides row layout in blue

I have a NSTableView that shows some images and a text in every row. I enabled multiple Selection for NSTableView. And I enabled Drag&Drop for TableView to sort or export the images. It now happens that, when I select more than one row, and dragging them over the TableView, that the whole row gets blue and remains blue (selected). Text and images can not been seen. In XCode I get this message:

Layout still needs update after calling -[NSTableRowView layout]. NSTableRowView or one of its superclasses may have overridden -layout without calling super. Or, something may have dirtied layout in the middle of updating it. Both are programming errors in Cocoa Autolayout. The former is pretty likely to arise if some pre-Cocoa Autolayout class had a method called layout, but it should be fixed.

The problem only exists for multiple Selection. When enabling single Selection it works fine.

Here are three pictures to demonstrate the problem:

Picture 2: When dragging over it gets complete blue; overriding the other layout components

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

Picture 3: After Dragging it remains fully blue

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

Until now I didn't find any solution or hint by googling two days. Perhaps here somebody have a hint?

like image 321
Daniel Avatar asked Nov 08 '14 09:11

Daniel


1 Answers

I was finally able to override the blue selection color by setting the selectionHighlightStyle of the row view. The following code in my NSTableRowView subclass did the trick:

- (NSTableViewSelectionHighlightStyle)selectionHighlightStyle
{
    return NSTableViewSelectionHighlightStyleNone;
}

- (void)drawSelectionInRect:(NSRect)dirtyRect
{
    [[NSColor redColor] set];
    NSRectFill(dirtyRect);
}
like image 173
adam.wulf Avatar answered Oct 26 '22 03:10

adam.wulf