diff options
author | CartBlanche <savagesoftware@gmail.com> | 2020-02-06 15:27:39 +0300 |
---|---|---|
committer | CartBlanche <savagesoftware@gmail.com> | 2020-02-27 16:07:59 +0300 |
commit | 9f4f8f52a6fdae38a0cccb141745194fc6e10426 (patch) | |
tree | 19cfc6a755fb5d6c562df4a236f677dbabc118f1 /Xamarin.PropertyEditing.Mac/Controls | |
parent | b9cc9e83798d73d56bde64f4f89da85b24e19cb9 (diff) |
[Mac] Tabbing to OutlineView
Diffstat (limited to 'Xamarin.PropertyEditing.Mac/Controls')
-rw-r--r-- | Xamarin.PropertyEditing.Mac/Controls/CategoryContainerControl.cs | 44 | ||||
-rw-r--r-- | Xamarin.PropertyEditing.Mac/Controls/PropertyEditorControl.cs | 6 |
2 files changed, 49 insertions, 1 deletions
diff --git a/Xamarin.PropertyEditing.Mac/Controls/CategoryContainerControl.cs b/Xamarin.PropertyEditing.Mac/Controls/CategoryContainerControl.cs new file mode 100644 index 0000000..dfec28e --- /dev/null +++ b/Xamarin.PropertyEditing.Mac/Controls/CategoryContainerControl.cs @@ -0,0 +1,44 @@ +using System; +using AppKit; + +namespace Xamarin.PropertyEditing.Mac +{ + internal class CategoryContainerControl + : PropertyEditorControl + { + private NSOutlineView outlineView; + private NSButton disclosure; + + public CategoryContainerControl (IHostResourceProvider hostResources, NSOutlineView outlineView) : base (hostResources) + { + if (outlineView == null) + throw new ArgumentNullException (nameof (outlineView)); + + this.outlineView = outlineView; + + this.disclosure = this.outlineView.MakeView ("NSOutlineViewDisclosureButtonKey", outlineView) as NSButton; + this.disclosure.TranslatesAutoresizingMaskIntoConstraints = false; + AddSubview (this.disclosure); + + var label = new UnfocusableTextField { + TranslatesAutoresizingMaskIntoConstraints = false + }; + AddSubview (label); + + AddConstraints (new[] { + NSLayoutConstraint.Create (this.disclosure, NSLayoutAttribute.CenterY, NSLayoutRelation.Equal, this, NSLayoutAttribute.CenterY, 1, 0), + NSLayoutConstraint.Create (this.disclosure, NSLayoutAttribute.Left, NSLayoutRelation.Equal, this, NSLayoutAttribute.Left, 1, 4), + NSLayoutConstraint.Create (label, NSLayoutAttribute.Left, NSLayoutRelation.Equal, this.disclosure, NSLayoutAttribute.Right, 1, 0), + NSLayoutConstraint.Create (label, NSLayoutAttribute.Height, NSLayoutRelation.Equal, this, NSLayoutAttribute.Height, 1, 0), + }); + } + + public override bool IsDynamicallySized => false; + + public override bool NeedsPropertyButton => false; + + public override NSView FirstKeyView => this.disclosure; + + public override NSView LastKeyView => this.disclosure; + } +} diff --git a/Xamarin.PropertyEditing.Mac/Controls/PropertyEditorControl.cs b/Xamarin.PropertyEditing.Mac/Controls/PropertyEditorControl.cs index bdbef92..e2d5eb9 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/PropertyEditorControl.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/PropertyEditorControl.cs @@ -86,7 +86,11 @@ namespace Xamarin.PropertyEditing.Mac do { row--; view = TableView.GetView (0, row, makeIfNecessary: false); - ctrl = (view as EditorContainer)?.EditorView?.NativeView as PropertyEditorControl; + if (view is PropertyEditorControl pec) { // This is to include the CategoryContainer + ctrl = pec; + } else { + ctrl = (view as EditorContainer)?.EditorView?.NativeView as PropertyEditorControl; + } } while (row > 0 && ctrl == null); if (ctrl != null) { |