Add keyboard shortcut support to ButtonWidgets.

Hook up 'escape' and 'return' as appropriate for moving through menus.
This commit is contained in:
Paul Chote
2011-05-23 19:38:49 +12:00
parent 124f19f00b
commit 81515705ec
18 changed files with 44 additions and 2 deletions

View File

@@ -17,6 +17,7 @@ namespace OpenRA.Widgets
{
public class ButtonWidget : Widget
{
public string Key = null;
public string Text = "";
public bool Depressed = false;
public int VisualHeight = ChromeMetrics.GetInt("ButtonDepth");
@@ -48,7 +49,16 @@ namespace OpenRA.Widgets
Depressed = false;
return base.LoseFocus(mi);
}
public override bool HandleKeyPressInner(KeyInput e)
{
if (e.KeyName != Key || e.Modifiers != Modifiers.None || e.Event != KeyInputEvent.Down)
return false;
OnClick();
return true;
}
public override bool HandleMouseInput(MouseInput mi)
{
if (mi.Button != MouseButton.Left)