Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve usability and fix some issues with hotkey remap dialog #16816

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 7 additions & 11 deletions OpenRA.Mods.Common/Widgets/HotkeyEntryWidget.cs
Expand Up @@ -24,10 +24,7 @@ public class HotkeyEntryWidget : Widget
public int LeftMargin = 5;
public int RightMargin = 5;

public Action OnTakeFocus = () => { };
public Action OnLoseFocus = () => { };
public Action OnEscape = () => { };
public Action OnReturn = () => { };

public Func<bool> IsDisabled = () => false;
public Func<bool> IsValid = () => false;
Expand All @@ -49,7 +46,6 @@ protected HotkeyEntryWidget(HotkeyEntryWidget widget)

public override bool TakeKeyboardFocus()
{
OnTakeFocus();
return base.TakeKeyboardFocus();
}

Expand All @@ -62,6 +58,12 @@ public override bool YieldKeyboardFocus()
return base.YieldKeyboardFocus();
}

public bool ForceYieldKeyboardFocus()
{
OnLoseFocus();
return base.YieldKeyboardFocus();
}

public override bool HandleMouseInput(MouseInput mi)
{
if (IsDisabled())
Expand Down Expand Up @@ -95,15 +97,9 @@ public override bool HandleKeyPress(KeyInput e)
if (!HasKeyboardFocus || IgnoreKeys.Contains(e.Key))
return false;

if (e.Key != Keycode.ESCAPE && e.Key != Keycode.RETURN)
if (e.Key != Keycode.ESCAPE && e.Key != Keycode.RETURN && e.Key != Keycode.KP_ENTER)
Key = Hotkey.FromKeyInput(e);

if (e.Key == Keycode.ESCAPE)
OnEscape();

if (e.Key == Keycode.RETURN)
OnReturn();

YieldKeyboardFocus();

return true;
Expand Down
149 changes: 0 additions & 149 deletions OpenRA.Mods.Common/Widgets/Logic/HotkeyDialogLogic.cs

This file was deleted.