From 0f4a14a4c2968b212a4109cfc1eb89867cab1bdc Mon Sep 17 00:00:00 2001 From: Jose Medrano Date: Wed, 16 Feb 2022 18:18:33 +0100 Subject: Creates ProxyRowResponder manage responder between rows in NSOutlineView --- .../Controls/ProxyRowResponder.cs | 48 ++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 Xamarin.PropertyEditing.Mac/Controls/ProxyRowResponder.cs diff --git a/Xamarin.PropertyEditing.Mac/Controls/ProxyRowResponder.cs b/Xamarin.PropertyEditing.Mac/Controls/ProxyRowResponder.cs new file mode 100644 index 0000000..6f0784e --- /dev/null +++ b/Xamarin.PropertyEditing.Mac/Controls/ProxyRowResponder.cs @@ -0,0 +1,48 @@ +using System; + +namespace Xamarin.PropertyEditing.Mac +{ + internal enum ProxyRowType + { + SingleView, + FirstView, + LastView + } + + internal class ProxyRowResponder + { + protected WeakReference editorControl; + + readonly ProxyRowType rowType; + + public ProxyRowResponder (PropertyEditorControl editorControl, ProxyRowType rowType) + { + this.rowType = rowType; + this.editorControl = new WeakReference (editorControl); + } + + public bool NextResponder() + { + if (this.editorControl.TryGetTarget (out var editor)) + { + if (this.rowType == ProxyRowType.LastView || this.rowType == ProxyRowType.SingleView) { + editor.OnNextResponderRequested (); + return true; + } + } + return false; + } + + public bool PreviousResponder () + { + if (this.editorControl.TryGetTarget (out var editor)) + { + if (this.rowType == ProxyRowType.FirstView || this.rowType == ProxyRowType.SingleView) { + editor.OnPreviousResponderRequested (); + return true; + } + } + return false; + } + } +} -- cgit v1.2.3