diff options
author | Eric Maupin <me@ermau.com> | 2019-03-01 20:44:04 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-01 20:44:04 +0300 |
commit | 1b4da57c501b14b295a90f0a57aea526ba637dc5 (patch) | |
tree | f30b240a053fb04c79143a3a40adc9946bbc116b /Xamarin.PropertyEditing.Mac/Controls/Custom | |
parent | 6e97c78ae1d505b3cd095cc830345d5271da04e4 (diff) | |
parent | 743e3fa1caad6948c17ca7407cbbfabce17acc63 (diff) |
Merge pull request #545 from xamarin/dominique-ScrollControlIntoViewWhenTabbing
[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; + } } } |