diff options
author | Eric Maupin <ermaup@microsoft.com> | 2019-02-01 20:37:03 +0300 |
---|---|---|
committer | Eric Maupin <ermaup@microsoft.com> | 2019-02-15 21:00:44 +0300 |
commit | 5fc4290bc2563e032281da7e1eb02260f117c6d1 (patch) | |
tree | a218b7e12c218ca8b1c6be809e6f3ef2e7caf854 /Xamarin.PropertyEditing.Mac | |
parent | 81b032777944761fd0c1de398ad77700df65539b (diff) |
[mac] Fix row tracking
Diffstat (limited to 'Xamarin.PropertyEditing.Mac')
-rw-r--r-- | Xamarin.PropertyEditing.Mac/Controls/PropertyEditorControl.cs | 32 | ||||
-rw-r--r-- | Xamarin.PropertyEditing.Mac/PropertyTableDelegate.cs | 6 |
2 files changed, 15 insertions, 23 deletions
diff --git a/Xamarin.PropertyEditing.Mac/Controls/PropertyEditorControl.cs b/Xamarin.PropertyEditing.Mac/Controls/PropertyEditorControl.cs index 5b33084..7106b79 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/PropertyEditorControl.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/PropertyEditorControl.cs @@ -20,7 +20,6 @@ namespace Xamarin.PropertyEditing.Mac public abstract NSView FirstKeyView { get; } public abstract NSView LastKeyView { get; } - public nint TableRow { get; set; } = -1; public NSTableView TableView { get; set; } public const int DefaultControlHeight = 22; @@ -70,26 +69,23 @@ namespace Xamarin.PropertyEditing.Mac public void UpdateKeyViews () { - if (TableRow < 0) + nint row = TableView.RowForView (this); + if (row <= 0) return; + NSView view; PropertyEditorControl ctrl = null; - - var tr = TableRow; - if (tr > 0) { - NSView view; - do { - tr--; - view = TableView.GetView (0, tr, false); - ctrl = (view as EditorContainer)?.EditorView?.NativeView as PropertyEditorControl; - } while (tr > 0 && ctrl == null); - - if (ctrl != null) { - ctrl.LastKeyView.NextKeyView = FirstKeyView; - ctrl.UpdateKeyViews (); - } else if (tr == 0 && view is PanelHeaderEditorControl header) { - header.SetNextKeyView (FirstKeyView); - } + do { + row--; + view = TableView.GetView (0, row, makeIfNecessary: false); + ctrl = (view as EditorContainer)?.EditorView?.NativeView as PropertyEditorControl; + } while (row > 0 && ctrl == null); + + if (ctrl != null) { + ctrl.LastKeyView.NextKeyView = FirstKeyView; + ctrl.UpdateKeyViews (); + } else if (row == 0 && view is PanelHeaderEditorControl header) { + header.SetNextKeyView (FirstKeyView); } } diff --git a/Xamarin.PropertyEditing.Mac/PropertyTableDelegate.cs b/Xamarin.PropertyEditing.Mac/PropertyTableDelegate.cs index f37a8de..e25efbb 100644 --- a/Xamarin.PropertyEditing.Mac/PropertyTableDelegate.cs +++ b/Xamarin.PropertyEditing.Mac/PropertyTableDelegate.cs @@ -90,15 +90,11 @@ namespace Xamarin.PropertyEditing.Mac } if (editor != null) { - nint index = outlineView.RowForItem (item); - if (editor.NativeView is PropertyEditorControl pec) { - pec.TableRow = index; - } - editor.ViewModel = evm; // Force a row update due to new height, but only when we are non-default if (editor.IsDynamicallySized) { + nint index = outlineView.RowForItem (item); outlineView.NoteHeightOfRowsWithIndexesChanged (new NSIndexSet (index)); } } else if (editorOrContainer is PanelHeaderEditorControl header) { |