Index: binaries/data/mods/public/gui/common/functions_global_object.js
===================================================================
--- binaries/data/mods/public/gui/common/functions_global_object.js
+++ binaries/data/mods/public/gui/common/functions_global_object.js
@@ -26,7 +26,12 @@
g_MessageBoxCallbackArgs = [];
};
-function messageBox(mbWidth, mbHeight, mbMessage, mbTitle, mbButtonCaptions, mbBtnCode, mbCallbackArgs)
+/*
+ * Create message box
+ * @param mbBtnCodeHotkeys - Array with binding hotkey to callback from btnCode by index to "cancel", "confirm" hotkey.
+ */
+function messageBox(mbWidth, mbHeight, mbMessage, mbTitle, mbButtonCaptions, mbBtnCode, mbCallbackArgs,
+ mbBtnCodeHotkeys)
{
if (g_MessageBoxBtnFunctions && g_MessageBoxBtnFunctions.length)
{
@@ -37,13 +42,17 @@
g_MessageBoxBtnFunctions = mbBtnCode;
g_MessageBoxCallbackArgs = mbCallbackArgs || g_MessageBoxCallbackArgs;
+ let hotkeys = mbBtnCodeHotkeys || ["cancel"];
+ hotkeys[mbBtnCode && mbBtnCode.length - 1 || 0] = mbBtnCodeHotkeys || "confirm";
+
Engine.PushGuiPage("page_msgbox.xml", {
"width": mbWidth,
"height": mbHeight,
"message": mbMessage,
"title": mbTitle,
"buttonCaptions": mbButtonCaptions,
- "callback": mbBtnCode && "g_MessageBoxCallbackFunction"
+ "callback": mbBtnCode && "g_MessageBoxCallbackFunction",
+ "hotkeys": hotkeys
});
}
Index: binaries/data/mods/public/gui/manual/intro.txt
===================================================================
--- binaries/data/mods/public/gui/manual/intro.txt
+++ binaries/data/mods/public/gui/manual/intro.txt
@@ -51,6 +51,8 @@
Shift + F2: Take huge screenshot (6400px*4800px, in .bmp format, location is displayed in the top left of the GUI after the file has been saved, and can also be seen in the console/logs if you miss it there)
Alt + S: Switch to the next tab.
Alt + W: Switch to the previous tab.
+ESC: Cancel and close message dialog
+Enter: Confirm and close message dialog
[font="sans-bold-14"]In Game
[font="sans-14"]Double Left Click \[on unit]: Select all of your units of the same kind on the screen (even if they're different ranks)
Index: binaries/data/mods/public/gui/msgbox/msgbox.js
===================================================================
--- binaries/data/mods/public/gui/msgbox/msgbox.js
+++ binaries/data/mods/public/gui/msgbox/msgbox.js
@@ -15,7 +15,18 @@
// Default behaviour
let mbCancelHotkey = Engine.GetGUIObjectByName("mbCancelHotkey");
- mbCancelHotkey.onPress = Engine.PopGuiPage;
+ let mbConfirmHotkey = Engine.GetGUIObjectByName("mbConfirmHotkey");
+
+ let popGui = (i) =>
+ {
+ if (data.callback)
+ Engine.PopGuiPageCB(i);
+ else
+ Engine.PopGuiPage();
+ };
+
+ // default esc always pop dialog
+ mbCancelHotkey.onPress = popGui;
// Calculate size
let mbLRDiff = data.width / 2;
@@ -29,21 +40,15 @@
captions.forEach((caption, i) => {
mbButton[i] = Engine.GetGUIObjectByName("mbButton" + (i + 1));
- let action = function()
- {
- if (data.callback)
- Engine.PopGuiPageCB(i);
- else
- Engine.PopGuiPage();
- };
-
mbButton[i].caption = caption;
- mbButton[i].onPress = action;
+ mbButton[i].onPress = () => popGui(i);
mbButton[i].hidden = false;
- // Convention: Cancel is the first button
- if (i == 0)
- mbCancelHotkey.onPress = action;
+ if (data.hotkeys && data.hotkeys.indexOf("cancel") == i)
+ mbCancelHotkey.onPress = () => popGui(i);
+
+ if (data.hotkeys && data.hotkeys.indexOf("confirm") == i)
+ mbConfirmHotkey.onPress = () => popGui(i);
});
// Distribute buttons horizontally
Index: binaries/data/mods/public/gui/msgbox/msgbox.xml
===================================================================
--- binaries/data/mods/public/gui/msgbox/msgbox.xml
+++ binaries/data/mods/public/gui/msgbox/msgbox.xml
@@ -8,6 +8,7 @@
+