Skip to content
This repository has been archived by the owner on Sep 25, 2024. It is now read-only.

Commit

Permalink
[Mac] Use the NSView.Tag property to set which control is the 1st one…
Browse files Browse the repository at this point in the history
… to receive focus.
  • Loading branch information
CartBlanche committed Dec 17, 2019
1 parent 47791d4 commit 91afd92
Show file tree
Hide file tree
Showing 18 changed files with 30 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ protected BasePointEditorControl (IHostResourceProvider hostResources)

XEditor = new NumericSpinEditor<T> (hostResources) {
BackgroundColor = NSColor.Clear,
Tag = 1,
Value = 0.0f
};
XEditor.ValueChanged += OnInputUpdated;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ protected BaseRectangleEditorControl (IHostResourceProvider hostResources)
};
XEditor = new NumericSpinEditor<T> (hostResources) {
BackgroundColor = NSColor.Clear,
Tag = 1,
Value = 0.0f
};
XEditor.ValueChanged += OnInputUpdated;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ internal class BooleanEditorControl
public BooleanEditorControl (IHostResourceProvider hostResource)
: base (hostResource)
{
BooleanEditor = new FocusableBooleanButton ();
BooleanEditor = new FocusableBooleanButton () { Tag = 1 };

// update the value on 'enter'
BooleanEditor.Activated += (sender, e) => {
Expand Down
1 change: 1 addition & 0 deletions Xamarin.PropertyEditing.Mac/Controls/BrushEditorControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public BrushEditorControl (IHostResourceProvider hostResources)
this.popUpButton = new ColorPopUpButton {
ControlSize = NSControlSize.Small,
Font = NSFont.SystemFontOfSize (NSFont.SystemFontSizeForControlSize (NSControlSize.Small)),
Tag = 1,
TranslatesAutoresizingMaskIntoConstraints = false,
};

Expand Down
1 change: 1 addition & 0 deletions Xamarin.PropertyEditing.Mac/Controls/CharEditorControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ internal class CharEditorControl
public CharEditorControl (IHostResourceProvider hostResources)
: base (hostResources)
{
Entry.Tag = 1;
}

protected override EntryPropertyEditorDelegate<char> CreateDelegate (PropertyViewModel<char> viewModel)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ public CollectionInlineEditorControl (IHostResourceProvider hostResources)
Title = Properties.Resources.CollectionEditButton,
BezelStyle = NSBezelStyle.Rounded,
AccessibilityEnabled = true,
AccessibilityHelp = Properties.Resources.AccessibilityCollectionHelp
AccessibilityHelp = Properties.Resources.AccessibilityCollectionHelp,
Tag = 1,
};

this.openCollection.Activated += (o, e) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ protected override void OnViewModelChanged (PropertyViewModel oldModel)
}

checkbox.Title = choice.Name;
checkbox.Tag = i == 0 ? 1 : -1;

this.combinableList[checkbox] = choice;
top += subrowHeight;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,12 @@ public override string AccessibilityTitle {
set { this.numericEditor.AccessibilityTitle = value; }
}

public new nint Tag
{
get { return this.numericEditor.Tag; }
set { this.numericEditor.Tag = value; }
}

public virtual void Reset ()
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,8 @@ private void FocusClickedRow ()
private void MakeFocusableKeyViewFirstResponder (NSView[] subViews)
{
foreach (NSView item in subViews) {
if (item.CanBecomeKeyView) {
if (item.CanBecomeKeyView
&& item.Tag == 1) {
Window?.MakeFirstResponder (item);
break;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public DateTimeEditorControl (IHostResourceProvider hostResources)
DatePickerElements = NSDatePickerElementFlags.HourMinuteSecond | NSDatePickerElementFlags.YearMonthDateDay,
DatePickerStyle = NSDatePickerStyle.TextFieldAndStepper,
Font = NSFont.SystemFontOfSize (NSFont.SystemFontSizeForControlSize (NSControlSize.Small)),
Tag = 1,
TranslatesAutoresizingMaskIntoConstraints = false
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public FilePathEditorControl (IHostResourceProvider hostResource)
: base (hostResource)
{
this.currentTextField.ToolTip = this.currentTextField.PlaceholderString = string.Format (Properties.Resources.ChooseFileOrDirectory, Properties.Resources.File);
this.currentTextField.Tag = 1;
this.panel.CanChooseFiles = true;
this.panel.CanChooseDirectories = false;
this.revealPathButton.ToolTip = string.Format (Properties.Resources.RevealFileOrDirectory, Properties.Resources.File);
Expand Down
4 changes: 3 additions & 1 deletion Xamarin.PropertyEditing.Mac/Controls/NumericEditorControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ public NumericEditorControl (IHostResourceProvider hostResources)
{
base.TranslatesAutoresizingMaskIntoConstraints = false;

NumericEditor = new NumericSpinEditor<T> (hostResources);
NumericEditor = new NumericSpinEditor<T> (hostResources) {
Tag = 1
};
NumericEditor.ValueChanged += OnValueChanged;

var t = typeof (T);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public ObjectEditorControl (IHostResourceProvider hostResources)
this.createObject = new FocusableButton {
Title = Properties.Resources.New,
BezelStyle = NSBezelStyle.Rounded,
Tag = 1,
};
this.createObject.Activated += OnNewPressed;
AddSubview (this.createObject);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ private void RequirePopup()
},
ControlSize = NSControlSize.Small,
Font = NSFont.SystemFontOfSize (NSFont.SystemFontSizeForControlSize (NSControlSize.Small)),
Tag = 1,
TranslatesAutoresizingMaskIntoConstraints = false,
StringValue = String.Empty,
};
Expand Down Expand Up @@ -154,6 +155,7 @@ private void RequireComboBox()
},
ControlSize = NSControlSize.Small,
Font = NSFont.SystemFontOfSize (NSFont.SystemFontSizeForControlSize (NSControlSize.Small)),
Tag = 1,
TranslatesAutoresizingMaskIntoConstraints = false,
StringValue = String.Empty,
};
Expand Down
4 changes: 3 additions & 1 deletion Xamarin.PropertyEditing.Mac/Controls/RatioEditorControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ public RatioEditorControl (IHostResourceProvider hostResources)
{
base.TranslatesAutoresizingMaskIntoConstraints = false;

this.ratioEditor = new RatioEditor<T> (hostResources);
this.ratioEditor = new RatioEditor<T> (hostResources) {
Tag = 1,
};
this.ratioEditor.SetFormatter (null);

// update the value on keypress
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public StringEditorControl (IHostResourceProvider hostResources)
: base (hostResources)
{
this.lastKeyView = Entry;
Entry.Tag = 1;
}

public override NSView LastKeyView => this.lastKeyView;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ internal class TimeSpanEditorControl
public TimeSpanEditorControl (IHostResourceProvider hostResources)
: base (hostResources)
{
Entry.Tag = 1;
}

protected override EntryPropertyEditorDelegate<TimeSpan> CreateDelegate (PropertyViewModel<TimeSpan> viewModel)
Expand Down
1 change: 1 addition & 0 deletions Xamarin.PropertyEditing.Mac/Controls/TypeEditorControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public TypeEditorControl (IHostResourceProvider hostResources)

this.selectType = new FocusableButton {
BezelStyle = NSBezelStyle.Rounded,
Tag = 1,
Title = Properties.Resources.Select,
};
this.selectType.Activated += OnSelectPressed;
Expand Down

0 comments on commit 91afd92

Please sign in to comment.