Cancel hotkey rebind on Esc key press

This commit is contained in:
Ivaylo Draganov
2020-01-30 21:24:25 +02:00
committed by teinarss
parent 889e2152a4
commit 47f6e407d9
2 changed files with 19 additions and 3 deletions

View File

@@ -1060,6 +1060,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic
hotkeyEntryWidget = panel.Get<HotkeyEntryWidget>("HOTKEY_ENTRY");
hotkeyEntryWidget.IsValid = () => isHotkeyValid;
hotkeyEntryWidget.OnLoseFocus = ValidateHotkey;
hotkeyEntryWidget.OnEscKey = () =>
{
hotkeyEntryWidget.Key = modData.Hotkeys[selectedHotkeyDefinition.Name].GetValue();
};
}
void ValidateHotkey()
@@ -1070,6 +1074,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
if (isHotkeyValid)
SaveHotkey();
else
hotkeyEntryWidget.TakeKeyboardFocus();
}
void SaveHotkey()