Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/xamarin/Xamarin.PropertyEditing.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJose Medrano <josmed@microsoft.com>2022-02-16 20:20:26 +0300
committervs-mobiletools-engineering-service2 <valco@microsoft.com>2022-03-01 18:01:15 +0300
commit08840cce2a0120f1d8061f5c57e4ea2550a5e393 (patch)
tree7917b18923df994b8292dedca9e97513ce4605cc
parent0f4a14a4c2968b212a4109cfc1eb89867cab1bdc (diff)
Removes old hack to set next responder for one based in KeyDown events
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/PropertyEditorControl.cs94
1 files changed, 60 insertions, 34 deletions
diff --git a/Xamarin.PropertyEditing.Mac/Controls/PropertyEditorControl.cs b/Xamarin.PropertyEditing.Mac/Controls/PropertyEditorControl.cs
index e2d5eb9..7899c8c 100644
--- a/Xamarin.PropertyEditing.Mac/Controls/PropertyEditorControl.cs
+++ b/Xamarin.PropertyEditing.Mac/Controls/PropertyEditorControl.cs
@@ -64,43 +64,9 @@ namespace Xamarin.PropertyEditing.Mac
NSView INativeContainer.NativeView => this;
- [Export ("_primitiveSetDefaultNextKeyView:")]
- public void SetDefaultNextKeyView (NSView child)
- {
- if (child == FirstKeyView || child == LastKeyView) {
- UpdateKeyViews ();
- }
- }
public virtual bool NeedsPropertyButton => true;
- public void UpdateKeyViews ()
- {
- if (TableView != null) {
- nint row = TableView.RowForView (this);
- if (row <= 0)
- return;
-
- NSView view;
- PropertyEditorControl ctrl = null;
- do {
- row--;
- view = TableView.GetView (0, row, makeIfNecessary: false);
- 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) {
- ctrl.LastKeyView.NextKeyView = FirstKeyView;
- ctrl.UpdateKeyViews ();
- } else if (row == 0 && view is PanelHeaderEditorControl header) {
- header.SetNextKeyView (FirstKeyView);
- }
- }
- }
/// <remarks>You should treat the implementation of this as static.</remarks>
public virtual nint GetHeight (EditorViewModel vm)
@@ -146,6 +112,66 @@ namespace Xamarin.PropertyEditing.Mac
AppearanceChanged ();
}
+
+ public void OnNextResponderRequested ()
+ {
+ if (TableView != null) {
+ nint row = TableView.RowForView (this) + 1;
+
+ NSView view;
+ PropertyEditorControl ctrl = null;
+
+ for (; row < TableView.RowCount; row++) {
+ view = TableView.GetView (0, row, makeIfNecessary: false);
+ if (view is PropertyEditorControl pec) { // This is to include the CategoryContainer
+ ctrl = pec;
+ } else {
+ ctrl = (view as EditorContainer)?.EditorView?.NativeView as PropertyEditorControl;
+ }
+
+ if (ctrl != null && !ctrl.viewModel.IsInputEnabled) {
+ ctrl = null;
+ }
+
+ if (ctrl != null) {
+ Window?.MakeFirstResponder (ctrl.FirstKeyView);
+ return;
+ }
+ }
+ }
+ }
+
+ public void OnPreviousResponderRequested ()
+ {
+ if (TableView != null) {
+ nint row = TableView.RowForView (this) - 1;
+
+ NSView view;
+ PropertyEditorControl ctrl = null;
+
+ for (; row > 0; row--)
+ {
+ view = TableView.GetView (0, row, makeIfNecessary: false);
+ if (view is PropertyEditorControl pec) { // This is to include the CategoryContainer
+ ctrl = pec;
+ } else {
+ ctrl = (view as EditorContainer)?.EditorView?.NativeView as PropertyEditorControl;
+ }
+
+ if (ctrl != null && !ctrl.viewModel.IsInputEnabled) {
+ ctrl = null;
+ }
+
+ if (ctrl != null) {
+ Window?.MakeFirstResponder (ctrl.LastKeyView);
+ return;
+ } else if (row == 0 && view is PanelHeaderEditorControl header) {
+ Window?.MakeFirstResponder(header);
+ return;
+ }
+ }
+ }
+ }
}
internal abstract class PropertyEditorControl<TViewModel>