Bug 14864 - NSTextFieldCell in NSTableView text color changed on drag/drop.
Summary: NSTextFieldCell in NSTableView text color changed on drag/drop.
Status: RESOLVED INVALID
Alias: None
Product: Xamarin.Mac
Classification: Desktop
Component: Other ()
Version: 1.6.9
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Aaron Bockover [MSFT]
URL:
Depends on:
Blocks:
 
Reported: 2013-09-19 13:40 UTC by Jon Goldberger [MSFT]
Modified: 2013-09-19 14:54 UTC (History)
1 user (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Test case 1 (26.61 KB, application/zip)
2013-09-19 13:40 UTC, Jon Goldberger [MSFT]
Details
Test case 2 (27.17 KB, application/zip)
2013-09-19 13:41 UTC, Jon Goldberger [MSFT]
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED INVALID

Description Jon Goldberger [MSFT] 2013-09-19 13:40:43 UTC
Created attachment 4931 [details]
Test case 1

I do have another problem I ran into
with dragging and dropping from NSTableViews. I want to implement the
functionality that when an item is dragged from the right table to the left
table, that the changed item in the left table's text changes color to red,
giving the user a visual feedback of what has been changed so far. Attached
is the sample project I've been using where I record which row was changed
in "AcceptDrop" in the LeftTableViewDataSource and I change the text color
in "WillDisplayCell" in LeftTableViewDelegate. This approach seems to work,
but once an item is changed in the left table and then another item is
dragged over, that previous item loses its red color. After some debugging,
I cannot seem to find what pattern "WillDisplayCell" is executed in to see
if my logic is full proof or not (most likely not). Please let me know what
you think.

Test case: TableTest-1.zip
=============================================================================================================
I just wanted to see while this issue is being looked at if there is a way
to use a custom type to pass through drag and drop. Attached is the
slightly modified example where instead of passing an NSString through the
pasteboard I attempt to use a class I made called "Preset", it builds but
when running it crashes when I drag over an item. I know there may be a way
using some from of ID bound to the List of "Presets", but I'm out of ideas
at this point. Please let me know!

test case: TableTest-2.zip
==============================================================================================================
Comment 1 Jon Goldberger [MSFT] 2013-09-19 13:41:05 UTC
Created attachment 4932 [details]
Test case 2
Comment 3 Jon Goldberger [MSFT] 2013-09-19 14:39:33 UTC
Version info:
=== Xamarin Studio ===

Version 4.0.12 (build 3)
Installation UUID: 2cd9f385-04c1-48f0-b2c0-e31a4c0da72a
Runtime:
Mono 3.2.3 ((no/8d3b4b7)
GTK 2.24.20
GTK# (2.12.0.0)
Package version: 302030000

=== Apple Developer Tools ===

Xcode 5.0 (3330.25)
Build 5A11386k

=== Xamarin.Mac ===

Xamarin.Mac: 1.4.8

=== Xamarin.Android ===

Version: 4.8.1 (Starter Edition)
Android SDK: /Users/salgarcia/Library/Developer/Xamarin/android-sdk-mac_x86
Supported Android versions:
2.1 (API level 7)
2.2 (API level 8)
2.3 (API level 10)
3.1 (API level 12)
4.0 (API level 14)
Java SDK: /usr
java version "1.6.0_51"
Java(TM) SE Runtime Environment (build 1.6.0_51-b11-457-11M4509)
Java HotSpot(TM) 64-Bit Server VM (build 20.51-b01-457, mixed mode)

=== Xamarin.iOS ===

Version: 7.0.0.11 (Business Edition)
Hash: aa35ba3
Branch:
Build date: 2013-18-09 16:42:48-0400

=== Build Information ===

Release ID: 400120003
Git revision: 593d7acb1cb78ceeeb482d5133cf1fe514467e39
Build date: 2013-08-07 20:30:53+0000
Xamarin addins: 25a0858b281923e666b09259ad4746b774e0a873

=== Operating System ===

Mac OS X 10.8.5
Darwin Sal-Garcia-MacBook-Pro.local 12.5.0 Darwin Kernel Version 12.5.0
Mon Jul 29 16:33:49 PDT 2013
root:xnu-2050.48.11~1/RELEASE_X86_64 x86_64
Comment 4 Aaron Bockover [MSFT] 2013-09-19 14:54:11 UTC
This is not a bug in the framework. There was flawed logic in the implementation of WillDisplayCell; the iteration was not terminated after a match was found, therefore the cell could reset to black after being set to red.

Correct WillDisplayCell:

public override void WillDisplayCell (NSTableView tableView, NSObject cell, NSTableColumn tableColumn, int row)
{
	((NSTextFieldCell)cell).TextColor = _source.ChangedRows.Contains (row)
		? NSColor.Red
		: NSColor.Black;
}