diff options
author | Eric Maupin <ermaup@microsoft.com> | 2019-05-15 20:31:50 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-15 20:31:50 +0300 |
commit | eeb853e1c6fa451a699a56dee59c26ecddab5fac (patch) | |
tree | 4c6ffd18b18958221b7b898e66ee862390082ff5 /Xamarin.PropertyEditing.Mac | |
parent | b973e17b94b8dd320addb6ad1bc272f521a92fc7 (diff) | |
parent | cebb745116a3a6507e4b5cbc4e64773814381bc2 (diff) |
Merge pull request #596 from xamarin/dominique-Fix553
[Mac] Setting the Formatter by default breaks the RatioEditor rendering.
Diffstat (limited to 'Xamarin.PropertyEditing.Mac')
-rw-r--r-- | Xamarin.PropertyEditing.Mac/Controls/RatioEditorControl.cs | 9 | ||||
-rw-r--r-- | Xamarin.PropertyEditing.Mac/Extensions.cs | 24 |
2 files changed, 26 insertions, 7 deletions
diff --git a/Xamarin.PropertyEditing.Mac/Controls/RatioEditorControl.cs b/Xamarin.PropertyEditing.Mac/Controls/RatioEditorControl.cs index 2fd4404..7591c2b 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/RatioEditorControl.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/RatioEditorControl.cs @@ -15,13 +15,8 @@ namespace Xamarin.PropertyEditing.Mac { base.TranslatesAutoresizingMaskIntoConstraints = false; - this.ratioEditor = new RatioEditor<T> (hostResources) { - AllowNegativeValues = false, - AllowRatios = true, - BackgroundColor = NSColor.Clear, - StringValue = string.Empty, - TranslatesAutoresizingMaskIntoConstraints = false, - }; + this.ratioEditor = new RatioEditor<T> (hostResources); + this.ratioEditor.SetFormatter (null); // update the value on keypress this.ratioEditor.ValueChanged += (sender, e) => { diff --git a/Xamarin.PropertyEditing.Mac/Extensions.cs b/Xamarin.PropertyEditing.Mac/Extensions.cs new file mode 100644 index 0000000..de9fdce --- /dev/null +++ b/Xamarin.PropertyEditing.Mac/Extensions.cs @@ -0,0 +1,24 @@ +using System; +using System.Runtime.InteropServices; +using AppKit; +using Foundation; + +namespace Xamarin.PropertyEditing.Mac +{ + internal static class Extensions + { + internal const string LIBOBJC_DYLIB = "/usr/lib/libobjc.dylib"; + + [DllImport (LIBOBJC_DYLIB, EntryPoint = "objc_msgSend")] + public extern static void void_objc_msgSend_intptr (IntPtr receiver, IntPtr selector, IntPtr arg1); + + const string selSetFormatter = "setFormatter:"; + static readonly IntPtr selSetFormatter_Handle = ObjCRuntime.Selector.GetHandle (selSetFormatter); + + internal static void SetFormatter (this NumericSpinEditor control, NSFormatter formatter) + { + IntPtr pointer = formatter != null ? formatter.Handle : IntPtr.Zero; + void_objc_msgSend_intptr (control.NumericEditor.Handle, selSetFormatter_Handle, pointer); + } + } +} |