diff --git a/OpenRA.Game/Widgets/ButtonWidget.cs b/OpenRA.Game/Widgets/ButtonWidget.cs index 9159a58f32..e9a5d545e2 100644 --- a/OpenRA.Game/Widgets/ButtonWidget.cs +++ b/OpenRA.Game/Widgets/ButtonWidget.cs @@ -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) diff --git a/OpenRA.Game/Widgets/Widget.cs b/OpenRA.Game/Widgets/Widget.cs index 70b0e29455..124562ad42 100644 --- a/OpenRA.Game/Widgets/Widget.cs +++ b/OpenRA.Game/Widgets/Widget.cs @@ -245,7 +245,7 @@ namespace OpenRA.Widgets return false; // Can any of our children handle this? - foreach (var child in Children) + foreach (var child in Children.OfType().Reverse()) if (child.HandleKeyPressOuter(e)) return true; diff --git a/mods/cnc/chrome/cheats.yaml b/mods/cnc/chrome/cheats.yaml index cc55403bc7..21cf14a516 100644 --- a/mods/cnc/chrome/cheats.yaml +++ b/mods/cnc/chrome/cheats.yaml @@ -69,6 +69,7 @@ Container@CHEATS_PANEL: Text:Show Unit Paths Button@CLOSE_BUTTON: Id:CLOSE_BUTTON + Key:escape X:0 Y:109 Width:140 diff --git a/mods/cnc/chrome/connection.yaml b/mods/cnc/chrome/connection.yaml index 77c3b68cd5..50ca617f58 100644 --- a/mods/cnc/chrome/connection.yaml +++ b/mods/cnc/chrome/connection.yaml @@ -28,6 +28,7 @@ Container@CONNECTING_PANEL: Align:Center Button@ABORT_BUTTON: Id:ABORT_BUTTON + Key:escape X:230 Y:89 Width:140 @@ -64,12 +65,14 @@ Container@CONNECTIONFAILED_PANEL: Align:Center Button@RETRY_BUTTON: Id:RETRY_BUTTON + Key:return Y:89 Width:140 Height:35 Text:Retry Button@ABORT_BUTTON: Id:ABORT_BUTTON + Key:escape X:230 Y:89 Width:140 diff --git a/mods/cnc/chrome/createserver.yaml b/mods/cnc/chrome/createserver.yaml index a88194bc38..50e1511b24 100644 --- a/mods/cnc/chrome/createserver.yaml +++ b/mods/cnc/chrome/createserver.yaml @@ -131,6 +131,7 @@ Container@CREATESERVER_PANEL: Text:1234 Button@BACK_BUTTON: Id:BACK_BUTTON + Key:escape X:0 Y:259 Width:140 @@ -145,6 +146,7 @@ Container@CREATESERVER_PANEL: Text:Choose Map Button@CREATE_BUTTON: Id:CREATE_BUTTON + Key:return X:464 Y:259 Width:140 diff --git a/mods/cnc/chrome/diplomacy.yaml b/mods/cnc/chrome/diplomacy.yaml index f8a9748f11..9ed0be2903 100644 --- a/mods/cnc/chrome/diplomacy.yaml +++ b/mods/cnc/chrome/diplomacy.yaml @@ -82,6 +82,7 @@ Container@DIPLOMACY_PANEL: Align:Center Button@BACK_BUTTON: Id:BACK_BUTTON + Key:escape Y:299 Width:140 Height:35 diff --git a/mods/cnc/chrome/directconnect.yaml b/mods/cnc/chrome/directconnect.yaml index f5f9483e0e..f0341023dd 100644 --- a/mods/cnc/chrome/directconnect.yaml +++ b/mods/cnc/chrome/directconnect.yaml @@ -46,6 +46,7 @@ Container@DIRECTCONNECT_PANEL: Height:25 Button@BACK_BUTTON: Id:BACK_BUTTON + Key:escape X:0 Y:89 Width:140 @@ -53,6 +54,7 @@ Container@DIRECTCONNECT_PANEL: Text:Back Button@JOIN_BUTTON: Id:JOIN_BUTTON + Key:return X:230 Y:89 Width:140 diff --git a/mods/cnc/chrome/dropdowns.yaml b/mods/cnc/chrome/dropdowns.yaml index e33996724b..0e590cfe02 100644 --- a/mods/cnc/chrome/dropdowns.yaml +++ b/mods/cnc/chrome/dropdowns.yaml @@ -7,6 +7,7 @@ Background@COLOR_CHOOSER: Children: Button@SAVE_BUTTON: Id:SAVE_BUTTON + Key:return X:210 Y:90 Width:90 diff --git a/mods/cnc/chrome/ingame.yaml b/mods/cnc/chrome/ingame.yaml index 6939f226d2..096c8de8c2 100644 --- a/mods/cnc/chrome/ingame.yaml +++ b/mods/cnc/chrome/ingame.yaml @@ -19,6 +19,7 @@ Container@INGAME_ROOT: Y: 40 Button@OPTIONS_BUTTON: Id:OPTIONS_BUTTON + Key:escape X:5 Y:5 Width:140 diff --git a/mods/cnc/chrome/ingamemenu.yaml b/mods/cnc/chrome/ingamemenu.yaml index 1f56eb5a67..041b410c2e 100644 --- a/mods/cnc/chrome/ingamemenu.yaml +++ b/mods/cnc/chrome/ingamemenu.yaml @@ -73,6 +73,7 @@ Container@INGAME_MENU: Text:Settings Button@RESUME_BUTTON: Id:RESUME_BUTTON + Key:escape X:600 Y:0 Width:140 @@ -107,12 +108,14 @@ Container@INGAME_MENU: Align:Center Button@CANCEL_BUTTON: Id:CANCEL_BUTTON + Key:escape Y:89 Width:140 Height:35 Text:Cancel Button@CONFIRM_BUTTON: Id:CONFIRM_BUTTON + Key:return X:230 Y:89 Width:140 diff --git a/mods/cnc/chrome/install.yaml b/mods/cnc/chrome/install.yaml index 9f70e27403..61f21de074 100644 --- a/mods/cnc/chrome/install.yaml +++ b/mods/cnc/chrome/install.yaml @@ -134,12 +134,14 @@ Container@INSTALL_FROMCD_PANEL: Text:Waiting for CD Button@BACK_BUTTON: Id:BACK_BUTTON + Key:escape Y:149 Width:140 Height:35 Text:Back Button@RETRY_BUTTON: Id:RETRY_BUTTON + Key:return X:500 Y:149 Width:140 @@ -187,12 +189,14 @@ Container@INSTALL_DOWNLOAD_PANEL: Text:Initialising... Button@CANCEL_BUTTON: Id:CANCEL_BUTTON + Key:escape Y:149 Width:140 Height:35 Text:Cancel Button@RETRY_BUTTON: Id:RETRY_BUTTON + Key:return X:500 Y:149 Width:140 diff --git a/mods/cnc/chrome/mainmenu.yaml b/mods/cnc/chrome/mainmenu.yaml index 8a6fa8045e..2343fe39a4 100644 --- a/mods/cnc/chrome/mainmenu.yaml +++ b/mods/cnc/chrome/mainmenu.yaml @@ -127,6 +127,7 @@ Container@MENU_BACKGROUND: Text:Direct Connect Button@BACK_BUTTON: Id:BACK_BUTTON + Key:escape X:600 Y:0 Width:140 @@ -169,6 +170,7 @@ Container@MENU_BACKGROUND: Text:Preferences Button@BACK_BUTTON: Id:BACK_BUTTON + Key:escape X:600 Y:0 Width:140 diff --git a/mods/cnc/chrome/mapchooser.yaml b/mods/cnc/chrome/mapchooser.yaml index 083d84c03e..e366916d6a 100644 --- a/mods/cnc/chrome/mapchooser.yaml +++ b/mods/cnc/chrome/mapchooser.yaml @@ -191,6 +191,7 @@ Container@MAPCHOOSER_PANEL: WordWrap:True Button@BUTTON_CANCEL: Id:BUTTON_CANCEL + Key:escape X:0 Y:499 Width:140 @@ -205,6 +206,7 @@ Container@MAPCHOOSER_PANEL: Text:Install Map Button@BUTTON_OK: Id:BUTTON_OK + Key:return X:600 Y:499 Width:140 diff --git a/mods/cnc/chrome/modchooser.yaml b/mods/cnc/chrome/modchooser.yaml index e776c27026..cd8077b043 100644 --- a/mods/cnc/chrome/modchooser.yaml +++ b/mods/cnc/chrome/modchooser.yaml @@ -80,6 +80,7 @@ Container@MODS_PANEL: Font:Bold Button@BACK_BUTTON: Id:BACK_BUTTON + Key:escape X:0 Y:499 Width:140 @@ -87,6 +88,7 @@ Container@MODS_PANEL: Text:Back Button@LOAD_BUTTON: Id:LOAD_BUTTON + Key:return X:600 Y:499 Width:140 diff --git a/mods/cnc/chrome/music.yaml b/mods/cnc/chrome/music.yaml index 773f5b5669..4b1d46c1a0 100644 --- a/mods/cnc/chrome/music.yaml +++ b/mods/cnc/chrome/music.yaml @@ -186,6 +186,7 @@ Container@MUSIC_PANEL: Text:Loop Button@BACK_BUTTON: Id:BACK_BUTTON + Key:escape X:0 Y:399 Width:140 @@ -240,6 +241,7 @@ Container@INSTALL_MUSIC_PANEL: Text:Waiting for file Button@BACK_BUTTON: Id:BACK_BUTTON + Key:escape Y:149 Width:140 Height:35 diff --git a/mods/cnc/chrome/preferences.yaml b/mods/cnc/chrome/preferences.yaml index ed3ded259c..11a084f4ef 100644 --- a/mods/cnc/chrome/preferences.yaml +++ b/mods/cnc/chrome/preferences.yaml @@ -347,6 +347,7 @@ Container@SETTINGS_PANEL: Text:Input Button@CANCEL_BUTTON: Id:CANCEL_BUTTON + Key:escape X:450 Y:249 Width:140 @@ -354,6 +355,7 @@ Container@SETTINGS_PANEL: Text:Cancel Button@SAVE_BUTTON: Id:SAVE_BUTTON + Key:return X:600 Y:249 Width:140 diff --git a/mods/cnc/chrome/replaybrowser.yaml b/mods/cnc/chrome/replaybrowser.yaml index c20e535b3d..dc680d60d2 100644 --- a/mods/cnc/chrome/replaybrowser.yaml +++ b/mods/cnc/chrome/replaybrowser.yaml @@ -98,6 +98,7 @@ Container@REPLAYBROWSER_PANEL: Height:20 Button@CANCEL_BUTTON: Id:CANCEL_BUTTON + Key:escape X:0 Y:299 Width:140 @@ -105,6 +106,7 @@ Container@REPLAYBROWSER_PANEL: Text:Back Button@WATCH_BUTTON: Id:WATCH_BUTTON + Key:return X:380 Y:299 Width:140 diff --git a/mods/cnc/chrome/serverbrowser.yaml b/mods/cnc/chrome/serverbrowser.yaml index 371ca54e43..556eefe053 100644 --- a/mods/cnc/chrome/serverbrowser.yaml +++ b/mods/cnc/chrome/serverbrowser.yaml @@ -193,6 +193,7 @@ Container@SERVERBROWSER_PANEL: Height:20 Button@BACK_BUTTON: Id:BACK_BUTTON + Key:escape X:0 Y:499 Width:140 @@ -207,6 +208,7 @@ Container@SERVERBROWSER_PANEL: Text:Refresh Button@JOIN_BUTTON: Id:JOIN_BUTTON + Key:return X:600 Y:499 Width:140