diff options
author | Dominique Louis <dominique@MININT-P5QM3VP.europe.corp.microsoft.com> | 2019-02-25 04:51:45 +0300 |
---|---|---|
committer | Dominique Louis <dominique@BLADE51.redmond.corp.microsoft.com> | 2019-02-28 15:43:34 +0300 |
commit | 743e3fa1caad6948c17ca7407cbbfabce17acc63 (patch) | |
tree | aa50b6d10f5ea8a791e3658f3416ff90c8a3d104 /Xamarin.PropertyEditing.Mac/Controls/Custom | |
parent | 93ef5b2bf8f74ce3a46305e48f59f9f43ab98710 (diff) |
[Mac] When tabbing scroll focused control into view.
Diffstat (limited to 'Xamarin.PropertyEditing.Mac/Controls/Custom')
5 files changed, 104 insertions, 2 deletions
diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/FocusableBooleanButton.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/FocusableBooleanButton.cs new file mode 100644 index 0000000..219fb95 --- /dev/null +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/FocusableBooleanButton.cs @@ -0,0 +1,33 @@ +using System; +using AppKit; + +namespace Xamarin.PropertyEditing.Mac +{ + internal class FocusableBooleanButton : NSButton + { + public override bool CanBecomeKeyView { get { return Enabled; } } + + public FocusableBooleanButton () + { + AllowsExpansionToolTips = true; + AllowsMixedState = true; + Cell.LineBreakMode = NSLineBreakMode.TruncatingTail; + Cell.UsesSingleLineMode = true; + ControlSize = NSControlSize.Small; + Font = NSFont.FromFontName (PropertyEditorControl.DefaultFontName, PropertyEditorControl.DefaultFontSize); + Title = string.Empty; + TranslatesAutoresizingMaskIntoConstraints = false; + + SetButtonType (NSButtonType.Switch); + } + + public override bool BecomeFirstResponder () + { + var willBecomeFirstResponder = base.BecomeFirstResponder (); + if (willBecomeFirstResponder) { + ScrollRectToVisible (Bounds); + } + return willBecomeFirstResponder; + } + } +} diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/FocusableButton.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/FocusableButton.cs new file mode 100644 index 0000000..5dba23c --- /dev/null +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/FocusableButton.cs @@ -0,0 +1,31 @@ +using System; +using AppKit; + +namespace Xamarin.PropertyEditing.Mac +{ + internal class FocusableButton : NSButton + { + public override bool CanBecomeKeyView { get { return Enabled; } } + + public FocusableButton () + { + AllowsExpansionToolTips = true; + AllowsMixedState = true; + Cell.LineBreakMode = NSLineBreakMode.TruncatingTail; + Cell.UsesSingleLineMode = true; + ControlSize = NSControlSize.Small; + Font = NSFont.FromFontName (PropertyEditorControl.DefaultFontName, PropertyEditorControl.DefaultFontSize); + Title = string.Empty; + TranslatesAutoresizingMaskIntoConstraints = false; + } + + public override bool BecomeFirstResponder () + { + var willBecomeFirstResponder = base.BecomeFirstResponder (); + if (willBecomeFirstResponder) { + ScrollRectToVisible (Bounds); + } + return willBecomeFirstResponder; + } + } +} diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/FocusableComboBox.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/FocusableComboBox.cs index 401c2ce..577ce4b 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/FocusableComboBox.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/FocusableComboBox.cs @@ -1,10 +1,19 @@ -using Foundation; +using Foundation; using AppKit; namespace Xamarin.PropertyEditing.Mac { - class FocusableComboBox : NSComboBox + internal class FocusableComboBox : NSComboBox { + public override bool BecomeFirstResponder () + { + var willBecomeFirstResponder = base.BecomeFirstResponder (); + if (willBecomeFirstResponder) { + ScrollRectToVisible (Bounds); + } + return willBecomeFirstResponder; + } + public override bool ShouldBeginEditing (NSText textObject) { textObject.Delegate = new FocusableComboBoxDelegate (); diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/FocusablePopupButton.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/FocusablePopupButton.cs new file mode 100644 index 0000000..4c9d392 --- /dev/null +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/FocusablePopupButton.cs @@ -0,0 +1,20 @@ +using System; +using AppKit; +using CoreGraphics; + +namespace Xamarin.PropertyEditing.Mac +{ + internal class FocusablePopUpButton : NSPopUpButton + { + public override bool CanBecomeKeyView { get { return Enabled; } } + + public override bool BecomeFirstResponder () + { + var willBecomeFirstResponder = base.BecomeFirstResponder (); + if (willBecomeFirstResponder) { + ScrollRectToVisible (Bounds); + } + return willBecomeFirstResponder; + } + } +} diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/PropertyTextField.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/PropertyTextField.cs index 2e7e158..0f28e2a 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/PropertyTextField.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/PropertyTextField.cs @@ -11,5 +11,14 @@ namespace Xamarin.PropertyEditing.Mac Cell.LineBreakMode = NSLineBreakMode.TruncatingTail; Cell.UsesSingleLineMode = true; } + + public override bool BecomeFirstResponder () + { + var willBecomeFirstResponder = base.BecomeFirstResponder (); + if (willBecomeFirstResponder) { + ScrollRectToVisible (Bounds); + } + return willBecomeFirstResponder; + } } } |