From 050a44afca8ee044b781f4d99a1f8256dc63f606 Mon Sep 17 00:00:00 2001 From: Dominique Louis Date: Wed, 17 May 2017 12:37:17 +0100 Subject: Ported the SpinButton control and renamed it to NumericSpinEditor, added keyup and down support. --- .../Controls/BaseRectangleEditorControl.cs | 38 ++++++++++------------ 1 file changed, 17 insertions(+), 21 deletions(-) (limited to 'Xamarin.PropertyEditing.Mac/Controls/BaseRectangleEditorControl.cs') diff --git a/Xamarin.PropertyEditing.Mac/Controls/BaseRectangleEditorControl.cs b/Xamarin.PropertyEditing.Mac/Controls/BaseRectangleEditorControl.cs index 96537dc..b1ce41a 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/BaseRectangleEditorControl.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/BaseRectangleEditorControl.cs @@ -12,13 +12,13 @@ namespace Xamarin.PropertyEditing.Mac where T : struct { protected UnfocusableTextField XLabel { get; set; } - protected NSTextField XEditor { get; set; } + protected NumericSpinEditor XEditor { get; set; } protected UnfocusableTextField YLabel { get; set; } - protected NSTextField YEditor { get; set; } + protected NumericSpinEditor YEditor { get; set; } protected UnfocusableTextField WidthLabel { get; set; } - protected NSTextField WidthEditor { get; set; } + protected NumericSpinEditor WidthEditor { get; set; } protected UnfocusableTextField HeightLabel { get; set; } - protected NSTextField HeightEditor { get; set; } + protected NumericSpinEditor HeightEditor { get; set; } public override NSView FirstKeyView => XEditor; public override NSView LastKeyView => HeightEditor; @@ -31,32 +31,28 @@ namespace Xamarin.PropertyEditing.Mac public BaseRectangleEditorControl () { XLabel = new UnfocusableTextField (); - XEditor = new NSTextField (); + XEditor = new NumericSpinEditor (); XEditor.BackgroundColor = NSColor.Clear; - XEditor.StringValue = string.Empty; - XEditor.Activated += OnInputUpdated; - XEditor.EditingEnded += OnInputUpdated; + XEditor.Value = 0.0f; + XEditor.ValueChanged += OnInputUpdated; YLabel = new UnfocusableTextField (); - YEditor = new NSTextField (); + YEditor = new NumericSpinEditor (); YEditor.BackgroundColor = NSColor.Clear; - YEditor.StringValue = string.Empty; - YEditor.Activated += OnInputUpdated; - YEditor.EditingEnded += OnInputUpdated; + YEditor.Value = 0.0f; + YEditor.ValueChanged += OnInputUpdated; WidthLabel = new UnfocusableTextField (); - WidthEditor = new NSTextField (); + WidthEditor = new NumericSpinEditor (); WidthEditor.BackgroundColor = NSColor.Clear; - WidthEditor.StringValue = string.Empty; - WidthEditor.Activated += OnInputUpdated; - WidthEditor.EditingEnded += OnInputUpdated; + WidthEditor.Value = 0.0f; + WidthEditor.ValueChanged += OnInputUpdated; HeightLabel = new UnfocusableTextField (); - HeightEditor = new NSTextField (); + HeightEditor = new NumericSpinEditor (); HeightEditor.BackgroundColor = NSColor.Clear; - HeightEditor.StringValue = string.Empty; - HeightEditor.Activated += OnInputUpdated; - HeightEditor.EditingEnded += OnInputUpdated; + HeightEditor.Value = 0.0f; + HeightEditor.ValueChanged += OnInputUpdated; AddSubview (XLabel); AddSubview (XEditor); @@ -70,7 +66,7 @@ namespace Xamarin.PropertyEditing.Mac protected virtual void OnInputUpdated (object sender, EventArgs e) { - ViewModel.Value = (T)Activator.CreateInstance (typeof(T), XEditor.FloatValue, YEditor.FloatValue, WidthEditor.FloatValue, HeightEditor.FloatValue); + ViewModel.Value = (T)Activator.CreateInstance (typeof(T), XEditor.Value, YEditor.Value, WidthEditor.Value, HeightEditor.Value); } protected override void HandleErrorsChanged (object sender, System.ComponentModel.DataErrorsChangedEventArgs e) -- cgit v1.2.3