|
@@ -64,6 +64,7 @@ public class ColorPicker : View
|
|
|
Width = textFieldWidth
|
|
|
};
|
|
|
tfValue.HasFocusChanged += UpdateSingleBarValueFromTextField;
|
|
|
+ tfValue.Accept += (s, _)=>UpdateSingleBarValueFromTextField(s);
|
|
|
_textFields.Add (bar, tfValue);
|
|
|
}
|
|
|
|
|
@@ -153,6 +154,7 @@ public class ColorPicker : View
|
|
|
_tfName.Autocomplete = auto;
|
|
|
|
|
|
_tfName.HasFocusChanged += UpdateValueFromName;
|
|
|
+ _tfName.Accept += (_s, _) => UpdateValueFromName ();
|
|
|
}
|
|
|
|
|
|
private void CreateTextField ()
|
|
@@ -182,6 +184,7 @@ public class ColorPicker : View
|
|
|
Add (_tfHex);
|
|
|
|
|
|
_tfHex.HasFocusChanged += UpdateValueFromTextField;
|
|
|
+ _tfHex.Accept += (_,_)=> UpdateValueFromTextField();
|
|
|
}
|
|
|
|
|
|
private void DisposeOldViews ()
|
|
@@ -192,7 +195,6 @@ public class ColorPicker : View
|
|
|
|
|
|
if (_textFields.TryGetValue (bar, out TextField? tf))
|
|
|
{
|
|
|
- tf.HasFocusChanged -= UpdateSingleBarValueFromTextField;
|
|
|
Remove (tf);
|
|
|
tf.Dispose ();
|
|
|
}
|
|
@@ -214,7 +216,6 @@ public class ColorPicker : View
|
|
|
if (_tfHex != null)
|
|
|
{
|
|
|
Remove (_tfHex);
|
|
|
- _tfHex.HasFocusChanged -= UpdateValueFromTextField;
|
|
|
_tfHex.Dispose ();
|
|
|
_tfHex = null;
|
|
|
}
|
|
@@ -229,7 +230,6 @@ public class ColorPicker : View
|
|
|
if (_tfName != null)
|
|
|
{
|
|
|
Remove (_tfName);
|
|
|
- _tfName.HasFocusChanged -= UpdateValueFromName;
|
|
|
_tfName.Dispose ();
|
|
|
_tfName = null;
|
|
|
}
|
|
@@ -279,11 +279,18 @@ public class ColorPicker : View
|
|
|
|
|
|
private void UpdateSingleBarValueFromTextField (object? sender, HasFocusEventArgs e)
|
|
|
{
|
|
|
+ // if the new value of Focused is true then it is an enter event so ignore
|
|
|
if (e.NewValue)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
+ // it is a leave event so update
|
|
|
+ UpdateSingleBarValueFromTextField (sender);
|
|
|
+ }
|
|
|
+ private void UpdateSingleBarValueFromTextField (object? sender)
|
|
|
+ {
|
|
|
+
|
|
|
foreach (KeyValuePair<IColorBar, TextField> kvp in _textFields)
|
|
|
{
|
|
|
if (kvp.Value == sender)
|
|
@@ -296,13 +303,19 @@ public class ColorPicker : View
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void UpdateValueFromName (object? sender, HasFocusEventArgs e)
|
|
|
+ private void UpdateValueFromName (object sender, HasFocusEventArgs e)
|
|
|
{
|
|
|
+ // if the new value of Focused is true then it is an enter event so ignore
|
|
|
if (e.NewValue)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
+ // it is a leave event so update
|
|
|
+ UpdateValueFromName();
|
|
|
+ }
|
|
|
+ private void UpdateValueFromName ()
|
|
|
+ {
|
|
|
if (_tfName == null)
|
|
|
{
|
|
|
return;
|
|
@@ -321,11 +334,17 @@ public class ColorPicker : View
|
|
|
|
|
|
private void UpdateValueFromTextField (object? sender, HasFocusEventArgs e)
|
|
|
{
|
|
|
- if (e.NewValue)
|
|
|
+ // if the new value of Focused is true then it is an enter event so ignore
|
|
|
+ if (e.NewValue)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
+ // it is a leave event so update
|
|
|
+ UpdateValueFromTextField ();
|
|
|
+ }
|
|
|
+ private void UpdateValueFromTextField ()
|
|
|
+ {
|
|
|
if (_tfHex == null)
|
|
|
{
|
|
|
return;
|