diff --git a/lib/monomac b/lib/monomac index 063aa8bde5..35c6994baa 160000 --- a/lib/monomac +++ b/lib/monomac @@ -1 +1 @@ -Subproject commit 063aa8bde51061f7ed2f02fcab4450b677982bf1 +Subproject commit 35c6994baa8a72296b7e045dfce375868bde9d2e diff --git a/src/Eto.Mac/Forms/Cells/CellHandler.cs b/src/Eto.Mac/Forms/Cells/CellHandler.cs index 913a7e25c7..992e0d72fc 100644 --- a/src/Eto.Mac/Forms/Cells/CellHandler.cs +++ b/src/Eto.Mac/Forms/Cells/CellHandler.cs @@ -37,6 +37,8 @@ public interface ICellHandler void EnabledChanged(bool value); NSView GetViewForItem(NSTableView tableView, NSTableColumn tableColumn, int row, NSObject obj, Func getItem); + + void ViewRemoved(NSView view); } public class EtoCellTextField : EtoTextField @@ -136,6 +138,10 @@ public virtual Color GetForegroundColor(NSView view) public virtual void SetForegroundColor(NSView view, Color color) { } + + public virtual void ViewRemoved(NSView view) + { + } protected virtual void ReloadColumnData() { diff --git a/src/Eto.Mac/Forms/Cells/CustomCellHandler.cs b/src/Eto.Mac/Forms/Cells/CustomCellHandler.cs index 0a2760984a..dd3c2a651e 100644 --- a/src/Eto.Mac/Forms/Cells/CustomCellHandler.cs +++ b/src/Eto.Mac/Forms/Cells/CustomCellHandler.cs @@ -193,6 +193,16 @@ public override NSView GetViewForItem(NSTableView tableView, NSTableColumn table Callback.OnConfigureCell(Widget, view.Args, view.EtoControl); return view; } + + public override void ViewRemoved(NSView view) + { + base.ViewRemoved(view); + if (view is EtoCustomCellView etoView) + { + etoView.Args.SetItem(null); + Callback.OnConfigureCell(Widget, etoView.Args, etoView.EtoControl); + } + } } } diff --git a/src/Eto.Mac/Forms/Controls/GridColumnHandler.cs b/src/Eto.Mac/Forms/Controls/GridColumnHandler.cs index ace8e4696a..c848af74a4 100644 --- a/src/Eto.Mac/Forms/Controls/GridColumnHandler.cs +++ b/src/Eto.Mac/Forms/Controls/GridColumnHandler.cs @@ -51,6 +51,7 @@ public interface IDataColumnHandler : GridColumn.IHandler void SetObjectValue(object dataItem, NSObject val); new GridColumn Widget { get; } IDataViewHandler DataViewHandler { get; } + ICellHandler DataCellHandler { get; } bool AutoSizeColumn(NSRange? rowRange, bool force = false); void EnabledChanged(bool value); nfloat GetPreferredWidth(NSRange? range = null); diff --git a/src/Eto.Mac/Forms/Controls/GridViewHandler.cs b/src/Eto.Mac/Forms/Controls/GridViewHandler.cs index 3a41350bd7..37b6e380b9 100644 --- a/src/Eto.Mac/Forms/Controls/GridViewHandler.cs +++ b/src/Eto.Mac/Forms/Controls/GridViewHandler.cs @@ -419,6 +419,18 @@ public override NSView GetViewForItem(NSTableView tableView, NSTableColumn table return tableView.MakeView(tableColumn.Identifier, this); } + public override void DidRemoveRowView(NSTableView tableView, NSTableRowView rowView, nint row) + { + foreach (var col in Handler.ColumnHandlers) + { + if (col.DisplayIndex != -1) + { + var view = rowView.ViewAtColumn(col.DisplayIndex); + col.DataCellHandler?.ViewRemoved(view); + } + } + } + public override void DidDragTableColumn(NSTableView tableView, NSTableColumn tableColumn) { var h = Handler; diff --git a/src/Eto.Mac/Forms/Controls/TreeGridViewHandler.cs b/src/Eto.Mac/Forms/Controls/TreeGridViewHandler.cs index b417dc76a7..405f4b7c84 100644 --- a/src/Eto.Mac/Forms/Controls/TreeGridViewHandler.cs +++ b/src/Eto.Mac/Forms/Controls/TreeGridViewHandler.cs @@ -255,6 +255,18 @@ public override NSView GetView(NSOutlineView outlineView, NSTableColumn tableCol return outlineView.MakeView(tableColumn?.Identifier ?? string.Empty, this); } + public override void DidRemoveRowView(NSOutlineView outlineView, NSTableRowView rowView, nint row) + { + foreach (var col in Handler.ColumnHandlers) + { + if (col.DisplayIndex != -1) + { + var view = rowView.ViewAtColumn(col.DisplayIndex); + col.DataCellHandler?.ViewRemoved(view); + } + } + } + public override void DidDragTableColumn(NSOutlineView outlineView, NSTableColumn tableColumn) { var h = Handler;