Fix updating input fields on editing end without changes

Fixes #197
This commit is contained in:
Wojtek Figat
2021-02-03 22:34:11 +01:00
parent 9c348b284f
commit e3142e6408
2 changed files with 21 additions and 2 deletions

View File

@@ -49,6 +49,11 @@ namespace FlaxEditor.GUI.Input
/// </summary> /// </summary>
protected T _startSlideValue; protected T _startSlideValue;
/// <summary>
/// The text cached on editing start. Used to compare with the end result to detect changes.
/// </summary>
protected string _startEditText;
private Vector2 _startSlideLocation; private Vector2 _startSlideLocation;
/// <summary> /// <summary>
@@ -257,11 +262,23 @@ namespace FlaxEditor.GUI.Input
return base.OnMouseUp(location, button); return base.OnMouseUp(location, button);
} }
/// <inheritdoc />
protected override void OnEditBegin()
{
base.OnEditBegin();
_startEditText = _text;
}
/// <inheritdoc /> /// <inheritdoc />
protected override void OnEditEnd() protected override void OnEditEnd()
{ {
// Update value if (_startEditText != _text)
TryGetValue(); {
// Update value
TryGetValue();
}
_startEditText = null;
base.OnEditEnd(); base.OnEditEnd();
} }

View File

@@ -942,6 +942,8 @@ namespace FlaxEngine.GUI
{ {
base.OnLostFocus(); base.OnLostFocus();
if (IsReadOnly)
return;
OnEditEnd(); OnEditEnd();
} }