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

Commit 758df3a

Browse files
authored
Merge pull request #543 from xamarin/dominique-Fix499
Enabled must be set for ReadOnly to look and behave correctly. Als…
2 parents 1b4da57 + 6b2b898 commit 758df3a

File tree

9 files changed

+33
-17
lines changed

9 files changed

+33
-17
lines changed

Xamarin.PropertyEditing.Mac/Controls/BasePointEditorControl.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ protected override void UpdateErrorsDisplayed (IEnumerable errors)
9494

9595
protected override void SetEnabled ()
9696
{
97-
XEditor.Editable = ViewModel.Property.CanWrite;
98-
YEditor.Editable = ViewModel.Property.CanWrite;
97+
XEditor.Enabled = ViewModel.Property.CanWrite;
98+
YEditor.Enabled = ViewModel.Property.CanWrite;
9999
}
100100

101101
protected override void UpdateAccessibilityValues ()

Xamarin.PropertyEditing.Mac/Controls/BaseRectangleEditorControl.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,10 @@ protected override void UpdateErrorsDisplayed (IEnumerable errors)
150150

151151
protected override void SetEnabled ()
152152
{
153-
XEditor.Editable = ViewModel.Property.CanWrite;
154-
YEditor.Editable = ViewModel.Property.CanWrite;
155-
WidthEditor.Editable = ViewModel.Property.CanWrite;
156-
HeightEditor.Editable = ViewModel.Property.CanWrite;
153+
XEditor.Enabled = ViewModel.Property.CanWrite;
154+
YEditor.Enabled = ViewModel.Property.CanWrite;
155+
WidthEditor.Enabled = ViewModel.Property.CanWrite;
156+
HeightEditor.Enabled = ViewModel.Property.CanWrite;
157157
}
158158

159159
protected override void UpdateAccessibilityValues ()

Xamarin.PropertyEditing.Mac/Controls/CombinablePropertyEditor.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ protected override void OnViewModelChanged (PropertyViewModel oldModel)
102102
// Set our tabable order
103103
this.firstKeyView = this.combinableList.KeyAt (0);
104104
this.lastKeyView = this.combinableList.KeyAt (this.combinableList.Count - 1);
105+
106+
SetEnabled ();
105107
}
106108

107109
protected override void UpdateValue ()

Xamarin.PropertyEditing.Mac/Controls/Custom/SpinnerButton.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public override void ViewDidChangeEffectiveAppearance ()
4747

4848
private void UpdateImage ()
4949
{
50-
Image = (this.isMouseOver) ? this.mouseOverImage : this.image;
50+
Image = Enabled ? (this.isMouseOver) ? this.mouseOverImage : this.image : this.image;
5151
}
5252
}
5353
}

Xamarin.PropertyEditing.Mac/Controls/NumericEditorControl.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ protected NSNumberFormatter Formatter {
5959
public override NSView FirstKeyView => NumericEditor;
6060
public override NSView LastKeyView => NumericEditor.DecrementButton;
6161

62+
private bool CanEnable => ViewModel.Property.CanWrite && (((ViewModel.InputMode != null) && !ViewModel.InputMode.IsSingleValue) || (this.inputModePopup == null));
63+
6264
protected NSNumberFormatterStyle NumberStyle {
6365
get {
6466
return NumericEditor.NumberStyle; }
@@ -91,7 +93,7 @@ protected override void HandleErrorsChanged (object sender, System.ComponentMode
9193

9294
protected override void SetEnabled ()
9395
{
94-
NumericEditor.Editable = ViewModel.Property.CanWrite;
96+
NumericEditor.Enabled = CanEnable;
9597
if (this.inputModePopup != null)
9698
this.inputModePopup.Enabled = ViewModel.Property.CanWrite;
9799
}
@@ -108,7 +110,7 @@ protected override void UpdateValue()
108110
{
109111
if (this.underlyingType != null) {
110112
NumericEditor.StringValue = ViewModel.Value == null ? string.Empty : ViewModel.Value.ToString ();
111-
NumericEditor.Enabled = ((ViewModel.InputMode != null) && !ViewModel.InputMode.IsSingleValue) || (this.inputModePopup == null);
113+
NumericEditor.Enabled = CanEnable;
112114

113115
if (this.inputModePopup != null)
114116
this.inputModePopup.SelectItem ((ViewModel.InputMode == null) ? string.Empty : ViewModel.InputMode.Identifier);
@@ -126,7 +128,7 @@ protected override void UpdateAccessibilityValues ()
126128
NumericEditor.AccessibilityTitle = string.Format (LocalizationResources.AccessibilityNumeric, ViewModel.Property.Name);
127129

128130
if (this.inputModePopup != null) {
129-
this.inputModePopup.AccessibilityEnabled = NumericEditor.Enabled;
131+
this.inputModePopup.AccessibilityEnabled = this.inputModePopup.Enabled;
130132
this.inputModePopup.AccessibilityTitle = string.Format (LocalizationResources.AccessibilityInpueModeEditor, ViewModel.Property.Name);
131133
}
132134
}
@@ -174,6 +176,8 @@ protected override void OnViewModelChanged (PropertyViewModel oldModel)
174176
// If we are reusing the control we'll have to hid the inputMode if this doesn't have InputMode.
175177
if (this.inputModePopup != null)
176178
this.inputModePopup.Hidden = !ViewModel.HasInputModes;
179+
180+
SetEnabled ();
177181
}
178182
}
179183
}

Xamarin.PropertyEditing.Mac/Controls/PanelHeaderEditorControl.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public PanelViewModel ViewModel
100100
this.typeDisplay.StringValue = value?.TypeName ?? String.Empty;
101101
UpdateValue ();
102102
UpdateIcon ();
103-
this.propertyObjectName.Editable = !this.viewModel.IsObjectNameReadOnly;
103+
this.propertyObjectName.Enabled = !this.viewModel.IsObjectNameReadOnly;
104104
}
105105
}
106106

@@ -133,7 +133,7 @@ private void UpdateValue ()
133133
{
134134
this.propertyObjectName.StringValue = this.viewModel.ObjectName ?? string.Empty;
135135
this.propertyObjectName.AccessibilityTitle = string.Format (LocalizationResources.AccessibilityObjectName, nameof (viewModel.ObjectName));
136-
this.propertyObjectName.Editable = !this.viewModel.IsObjectNameReadOnly;
136+
this.propertyObjectName.Enabled = !this.viewModel.IsObjectNameReadOnly;
137137
}
138138

139139
private void OnObjectNameEdited (object sender, EventArgs e)

Xamarin.PropertyEditing.Mac/Controls/PredefinedValuesEditor.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,11 @@ protected override void UpdateErrorsDisplayed (IEnumerable errors)
9494

9595
protected override void OnViewModelChanged (PropertyViewModel oldModel)
9696
{
97+
base.OnViewModelChanged (oldModel);
98+
99+
if (ViewModel == null)
100+
return;
101+
97102
if (!this.dataPopulated) {
98103
if (ViewModel.IsConstrainedToPredefined) {
99104
this.popupButtonList.RemoveAllItems ();
@@ -136,7 +141,7 @@ protected override void OnViewModelChanged (PropertyViewModel oldModel)
136141
this.dataPopulated = true;
137142
}
138143

139-
base.OnViewModelChanged (oldModel);
144+
SetEnabled ();
140145
}
141146

142147
protected override void UpdateValue ()

Xamarin.PropertyEditing.Mac/Controls/RatioEditorControl.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ protected override void HandleErrorsChanged (object sender, DataErrorsChangedEve
4949

5050
protected override void SetEnabled ()
5151
{
52-
this.ratioEditor.Editable = ViewModel.Property.CanWrite;
52+
this.ratioEditor.Enabled = ViewModel.Property.CanWrite;
5353
}
5454

5555
protected override void UpdateAccessibilityValues ()

Xamarin.PropertyEditing.Mac/Controls/StringEditorControl.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ internal class StringEditorControl
2525
internal NSPopUpButton inputModePopup;
2626
private IReadOnlyList<InputMode> viewModelInputModes;
2727

28+
private bool CanEnable => ViewModel.Property.CanWrite && (((ViewModel.InputMode != null) && !ViewModel.InputMode.IsSingleValue) || (this.inputModePopup == null));
29+
2830
public StringEditorControl (IHostResourceProvider hostResource)
2931
: base (hostResource)
3032
{
@@ -56,7 +58,7 @@ public StringEditorControl (IHostResourceProvider hostResource)
5658
protected override void UpdateValue ()
5759
{
5860
this.stringEditor.StringValue = ViewModel.Value ?? string.Empty;
59-
this.stringEditor.Enabled = ((ViewModel.InputMode != null) && !ViewModel.InputMode.IsSingleValue) || (this.inputModePopup == null);
61+
this.stringEditor.Enabled = CanEnable;
6062
if (this.inputModePopup != null)
6163
this.inputModePopup.SelectItem ((ViewModel.InputMode == null) ? string.Empty : ViewModel.InputMode.Identifier);
6264
}
@@ -111,6 +113,8 @@ protected override void OnViewModelChanged (PropertyViewModel oldModel)
111113
// If we are reusing the control we'll have to hid the inputMode if this doesn't have InputMode.
112114
if (this.inputModePopup != null)
113115
this.inputModePopup.Hidden = !ViewModel.HasInputModes;
116+
117+
SetEnabled ();
114118
}
115119

116120
protected override void UpdateErrorsDisplayed (IEnumerable errors)
@@ -125,16 +129,17 @@ protected override void UpdateErrorsDisplayed (IEnumerable errors)
125129

126130
protected override void SetEnabled ()
127131
{
128-
this.stringEditor.Editable = ViewModel.Property.CanWrite;
132+
this.stringEditor.Enabled = CanEnable;
129133
if (this.inputModePopup != null)
130134
this.inputModePopup.Enabled = ViewModel.Property.CanWrite;
131135
}
132136

133137
protected override void UpdateAccessibilityValues ()
134138
{
135-
this.stringEditor.AccessibilityEnabled = this.stringEditor.Editable;
139+
this.stringEditor.AccessibilityEnabled = this.stringEditor.Enabled;
136140
this.stringEditor.AccessibilityTitle = string.Format (LocalizationResources.AccessibilityString, ViewModel.Property.Name);
137141
if (this.inputModePopup != null) {
142+
this.inputModePopup.AccessibilityEnabled = this.inputModePopup.Enabled;
138143
this.inputModePopup.AccessibilityTitle = string.Format (LocalizationResources.AccessibilityInpueModeEditor, ViewModel.Property.Name);
139144
}
140145
}

0 commit comments

Comments
 (0)