Add more robust input handling
This commit is contained in:
@@ -107,6 +107,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
actorEditPanel.IsVisible = () => editor.CurrentBrush == editor.DefaultBrush && SelectedActor != null;
|
actorEditPanel.IsVisible = () => editor.CurrentBrush == editor.DefaultBrush && SelectedActor != null;
|
||||||
|
|
||||||
actorIDField.OnEscKey = _ => actorIDField.YieldKeyboardFocus();
|
actorIDField.OnEscKey = _ => actorIDField.YieldKeyboardFocus();
|
||||||
|
actorIDField.OnEnterKey = _ => actorIDField.YieldKeyboardFocus();
|
||||||
|
|
||||||
actorIDField.OnTextEdited = () =>
|
actorIDField.OnTextEdited = () =>
|
||||||
{
|
{
|
||||||
@@ -121,26 +122,26 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
if (!SelectedActor.ID.Equals(actorId, StringComparison.OrdinalIgnoreCase) && editorActorLayer[actorId] != null)
|
if (!SelectedActor.ID.Equals(actorId, StringComparison.OrdinalIgnoreCase) && editorActorLayer[actorId] != null)
|
||||||
{
|
{
|
||||||
nextActorIDStatus = ActorIDStatus.Duplicate;
|
nextActorIDStatus = ActorIDStatus.Duplicate;
|
||||||
actorIDErrorLabel.Visible = true;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SetActorID(actorId);
|
SetActorID(actorId);
|
||||||
nextActorIDStatus = ActorIDStatus.Normal;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
actorIDField.OnLoseFocus = () =>
|
actorIDField.OnLoseFocus = () =>
|
||||||
{
|
{
|
||||||
// Reset invalid IDs back to their starting value
|
// Reset invalid IDs back to their starting value
|
||||||
if (actorIDStatus != ActorIDStatus.Normal)
|
if (actorIDStatus != ActorIDStatus.Normal)
|
||||||
|
{
|
||||||
SetActorID(initialActorID);
|
SetActorID(initialActorID);
|
||||||
|
actorIDField.Text = initialActorID;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetActorID(string actorId)
|
void SetActorID(string actorId)
|
||||||
{
|
{
|
||||||
editActorPreview.SetActorID(actorId);
|
editActorPreview.SetActorID(actorId);
|
||||||
|
|
||||||
nextActorIDStatus = ActorIDStatus.Normal;
|
nextActorIDStatus = ActorIDStatus.Normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user