Bug 12467 - NSTableView.SelectionDidChange problem
Summary: NSTableView.SelectionDidChange problem
Status: VERIFIED FIXED
Alias: None
Product: Xamarin.Mac
Classification: Desktop
Component: Library (Xamarin.Mac.dll) ()
Version: Master
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: 2.4.0 (C6)
Assignee: Chris Hamons
URL:
Depends on:
Blocks:
 
Reported: 2013-05-30 05:01 UTC by David Lambert
Modified: 2015-11-19 06:37 UTC (History)
6 users (show)

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


Attachments
TestSample (13.79 KB, application/zip)
2015-11-19 06:37 UTC, Rajneesh Kumar
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:
VERIFIED FIXED

Description David Lambert 2013-05-30 05:01:23 UTC
If I add a delegate to NSTableView.SelectionDidChange I cannot select rows anymore.
Comment 1 Aaron Bockover [MSFT] 2013-06-04 10:03:28 UTC
Hi David,

There definitely appears to be an issue with the events/delegates on NSTableView. For now as a workaround you can subclass NSTableViewDelegate and override the methods you care about. This appears to work as expected.

I'm looking into why the events/delegate properties directly on NSTableView are not working.

	public override void AwakeFromNib ()
	{
		tableView.Delegate = new TableDelegate ();
	}

	class TableDelegate : NSTableViewDelegate
	{
		public override void SelectionDidChange (NSNotification notification)
		{
			Console.WriteLine ("Selection Changed (delegate)");
		}

		public override bool ShouldSelectRow (NSTableView tableView, int row)
		{
			return row % 3 == 0;
		}
	}

Thanks!
Comment 2 David Lambert 2013-06-04 10:31:47 UTC
Thanks, it works well!
Comment 3 xamarin 2014-06-01 16:00:47 UTC
This happens in my case as well. Will try the workaround.
Comment 4 xamarin 2014-06-17 23:26:09 UTC
Yes, the workaround works.
Comment 6 Chris Hamons 2015-02-18 12:32:08 UTC
This should be fixed in master / 2491f2f734e3052aabbfa9ac76c60ec8e23d7748 and should be in XM 2.0 (this summer).

Events on base and derived classes should now not stomp each other. We are not supporting using both the c# events and delegate at the same time. If you try this in Unified, we will throw an exception (since one of them won't be called).
Comment 7 Rajneesh Kumar 2015-03-05 04:01:52 UTC
We are trying to verify this issue, but we are not sure about the steps to verify.

Could you please share steps or small sample to reproduce/check this issue? So that we can verify it efficiently.

Thanks
Comment 10 Chris Hamons 2015-05-14 09:55:13 UTC
@John Miller - It appears we had two issues at play here. Rajneesh was correct in that we didn't verify that the general fix for delegate/event issues fixed this specific issue. Apologies.

It appears SelectionShouldChange incorrectly defaults to returning false instead of true.

You can work around this via adding:

tableView.SelectionShouldChange += (t) => true;

if you use the events.
Comment 11 Chris Hamons 2015-05-14 10:28:31 UTC
Fixed in master / ceb756abed2250ebbbb0c9061c10c4edede96815. This will be available in XM 2.2, later this year.

QA - Open the mac-samples / NSOutlineViewAdnTableViewExampel and in NSTableViewExample.cs change

https://gist.github.com/chamons/92f4fc31a8c4b7d45d33

If the fix works, you'll be able to change selection in the table view tab.
Comment 12 Rajneesh Kumar 2015-11-19 06:37:36 UTC
Created attachment 13884 [details]
TestSample

This feature has been completed and merged as you can see the trello card.
https://trello.com/c/J1KQU345/858-maccore-master-multi-level-generate-testing

I have tested it may times and it is working fine at my end, I have attached test sample.

This issue has been fixed and working fine, hence I am closing this issue.

Thanks..!