Reputation: 1995
I am starting to learn Cocoa and Mono.
I have created an NSTableView which I have populated with some rows of data. Now I want to hook up some methods to the events ColumnDidMove, ColumnDidResize and MouseDownInHeaderOfTableColumn.
But whenever I add a listener to any of these events I am no longer able to select any rows or drag any columns. Clicking column headers for sorting or resizing them works, though.
What's wrong?
Upvotes: 0
Views: 242
Reputation: 12566
I'm not sure what the exact correct approach here is, however this might help you.
The events provided by the monomac bindings are implemented 'under the hood' as a generated delegate. The delegate encapsulates a lot of the functionality that you describe in the case of NSTableView
, including moving and resizing columns.
This is described here (refers to monotouch, but the concept is identical).
I think that what happens (and this may be wrong) once you subscribe an event, the delegate gets internally set to a generated implementation that does not provide all the required functionality. See this relevant bug.
You could try subscribing all the events that are exposed on NSTableView
and see if that helps.
Otherwise, the best way may be to get your notifications directly from your own delegate rather than using events, e.g.:
public override void AwakeFromNib()
{
tableView.Delegate = new MyDelegate();
}
private class MyDelegate : NSTableViewDelegate
{
public override void ColumnDidMove(NSNotification notification)
{
Console.WriteLine("column did move");
}
}
Upvotes: 1