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-24 12:48:56 +0300
committervs-mobiletools-engineering-service2 <valco@microsoft.com>2022-03-01 18:01:15 +0300
commit2ca0edb87fb052380e1730301eaa3199aea7ddda (patch)
treee37b485d4840517058f4d58fb7c084b10769dbd9
parenta86acaadaafd74105738862447953df0d9a1f16c (diff)
Refactoring in OnPreviousResponderRequested and OnNextResponderRequested
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/PropertyEditorControl.cs41
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/ProxyRowResponder.cs4
2 files changed, 10 insertions, 35 deletions
diff --git a/Xamarin.PropertyEditing.Mac/Controls/PropertyEditorControl.cs b/Xamarin.PropertyEditing.Mac/Controls/PropertyEditorControl.cs
index 110b86c..f8448ec 100644
--- a/Xamarin.PropertyEditing.Mac/Controls/PropertyEditorControl.cs
+++ b/Xamarin.PropertyEditing.Mac/Controls/PropertyEditorControl.cs
@@ -113,44 +113,18 @@ namespace Xamarin.PropertyEditing.Mac
AppearanceChanged ();
}
- public void OnNextResponderRequested ()
+ public void OnNextResponderRequested (bool reverse)
{
if (TableView != null) {
- nint row = TableView.RowForView (this) + 1;
+ var modifier = reverse ? -1 : 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?.viewModel != 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;
+ nint row = TableView.RowForView (this) + modifier;
NSView view;
PropertyEditorControl ctrl = null;
- for (; row > 0; row--)
- {
+ for (; reverse ? row > 0 : row < TableView.RowCount; row += modifier) {
+
view = TableView.GetView (0, row, makeIfNecessary: false);
if (view is PropertyEditorControl pec) { // This is to include the CategoryContainer
ctrl = pec;
@@ -163,10 +137,11 @@ namespace Xamarin.PropertyEditing.Mac
}
if (ctrl != null) {
- Window?.MakeFirstResponder (ctrl.LastKeyView);
+ var targetView = reverse ? ctrl.LastKeyView : ctrl.FirstKeyView;
+ Window?.MakeFirstResponder (targetView);
return;
} else if (row == 0 && view is PanelHeaderEditorControl header) {
- Window?.MakeFirstResponder(header);
+ Window?.MakeFirstResponder (header);
return;
}
}
diff --git a/Xamarin.PropertyEditing.Mac/Controls/ProxyRowResponder.cs b/Xamarin.PropertyEditing.Mac/Controls/ProxyRowResponder.cs
index 78f9563..ca613d1 100644
--- a/Xamarin.PropertyEditing.Mac/Controls/ProxyRowResponder.cs
+++ b/Xamarin.PropertyEditing.Mac/Controls/ProxyRowResponder.cs
@@ -26,7 +26,7 @@ namespace Xamarin.PropertyEditing.Mac
if (this.editorControl.TryGetTarget (out var editor))
{
if (this.rowType == ProxyRowType.LastView || this.rowType == ProxyRowType.SingleView) {
- editor.OnNextResponderRequested ();
+ editor.OnNextResponderRequested (false);
return true;
}
}
@@ -38,7 +38,7 @@ namespace Xamarin.PropertyEditing.Mac
if (this.editorControl.TryGetTarget (out var editor))
{
if (this.rowType == ProxyRowType.FirstView || this.rowType == ProxyRowType.SingleView) {
- editor.OnPreviousResponderRequested ();
+ editor.OnNextResponderRequested (true);
return true;
}
}