Index: binaries/data/mods/public/gui/session/hotkeys/misc.xml
===================================================================
--- binaries/data/mods/public/gui/session/hotkeys/misc.xml (revision 18090)
+++ binaries/data/mods/public/gui/session/hotkeys/misc.xml (working copy)
@@ -4,14 +4,14 @@
closeOpenDialogs();
-
+
Index: binaries/data/mods/public/gui/session/menu.js
===================================================================
--- binaries/data/mods/public/gui/session/menu.js (revision 18090)
+++ binaries/data/mods/public/gui/session/menu.js (working copy)
@@ -86,8 +86,8 @@
function chatMenuButton()
{
- closeOpenDialogs();
- openChat();
+ closeMenu();
+ openChatWindow();
}
function diplomacyMenuButton()
@@ -196,24 +196,15 @@
Engine.PushGuiPage("page_options.xml", { "callback": "resumeGame" });
}
-function openChat()
-{
- if (g_Disconnected)
- return;
-
- closeOpenDialogs();
-
- setTeamChat(false);
-
- Engine.GetGUIObjectByName("chatInput").focus(); // Grant focus to the input area
- Engine.GetGUIObjectByName("chatDialogPanel").hidden = false;
-}
-
function closeChat()
{
- Engine.GetGUIObjectByName("chatInput").caption = ""; // Clear chat input
- Engine.GetGUIObjectByName("chatInput").blur(); // Remove focus
- Engine.GetGUIObjectByName("chatDialogPanel").hidden = true;
+ let chatWindow = Engine.GetGUIObjectByName("chatDialogPanel");
+ if(!chatWindow.hidden)
+ {
+ Engine.GetGUIObjectByName("chatInput").caption = ""; // Clear chat input
+ Engine.GetGUIObjectByName("chatInput").blur(); // Remove focus
+ chatWindow.hidden = true;
+ }
}
/**
@@ -228,9 +219,9 @@
}
/**
- * Opens chat-window or closes it and sends the userinput.
+ * Opens or focuses chat-window.
*/
-function toggleChatWindow(teamChat)
+function openChatWindow(teamChat)
{
if (g_Disconnected)
return;
@@ -237,26 +228,17 @@
let chatWindow = Engine.GetGUIObjectByName("chatDialogPanel");
let chatInput = Engine.GetGUIObjectByName("chatInput");
- let hidden = chatWindow.hidden;
-
- closeOpenDialogs();
-
- if (hidden)
+ if(!chatWindow.hidden)
{
- setTeamChat(teamChat);
chatInput.focus();
+ return;
}
- else
- {
- if (chatInput.caption.length)
- {
- submitChatInput();
- return;
- }
- chatInput.caption = "";
- }
- chatWindow.hidden = !hidden;
+ closeOpenDialogs();
+ setTeamChat(teamChat);
+ chatInput.focus();
+
+ chatWindow.hidden = false;
}
function openDiplomacy()
Index: binaries/data/mods/public/gui/session/messages.js
===================================================================
--- binaries/data/mods/public/gui/session/messages.js (revision 18090)
+++ binaries/data/mods/public/gui/session/messages.js (working copy)
@@ -574,9 +574,7 @@
let input = Engine.GetGUIObjectByName("chatInput");
let text = input.caption;
- input.blur(); // Remove focus
- input.caption = ""; // Clear chat input
- toggleChatWindow();
+ closeChat();
if (!text.length)
return;
Index: source/gui/CGUI.cpp
===================================================================
--- source/gui/CGUI.cpp (revision 18090)
+++ source/gui/CGUI.cpp (working copy)
@@ -65,8 +65,22 @@
{
InReaction ret = IN_PASS;
- if (ev->ev.type == SDL_HOTKEYDOWN)
+ // Handle keys for input boxes
+ if ( GetFocusedObject() &&
+ ((ev->ev.type == SDL_KEYDOWN &&
+ ev->ev.key.keysym.sym != SDLK_ESCAPE &&
+ !g_keys[SDLK_LCTRL] && !g_keys[SDLK_RCTRL] &&
+ !g_keys[SDLK_LALT] && !g_keys[SDLK_RALT]) ||
+ ev->ev.type == SDL_HOTKEYDOWN || ev->ev.type == SDL_HOTKEYUP ||
+ (ev->ev.type == SDL_KEYUP && (ev->ev.key.keysym.sym == SDLK_KP_ENTER || ev->ev.key.keysym.sym == SDLK_RETURN)) ||
+ ev->ev.type == SDL_TEXTINPUT ||
+ ev->ev.type == SDL_TEXTEDITING) )
{
+ ret = GetFocusedObject()->ManuallyHandleEvent(ev);
+ }
+
+ else if (ev->ev.type == SDL_HOTKEYUP)
+ {
const char* hotkey = static_cast(ev->ev.user.data1);
std::map >::iterator it = m_HotkeyObjects.find(hotkey);
if (it != m_HotkeyObjects.end())
@@ -243,23 +257,7 @@
m_MousePos = oldMousePos;
}
- // Handle keys for input boxes
- if (GetFocusedObject())
- {
- if (
- (ev->ev.type == SDL_KEYDOWN &&
- ev->ev.key.keysym.sym != SDLK_ESCAPE &&
- !g_keys[SDLK_LCTRL] && !g_keys[SDLK_RCTRL] &&
- !g_keys[SDLK_LALT] && !g_keys[SDLK_RALT])
- || ev->ev.type == SDL_HOTKEYDOWN
- || ev->ev.type == SDL_TEXTINPUT || ev->ev.type == SDL_TEXTEDITING
- )
- {
- ret = GetFocusedObject()->ManuallyHandleEvent(ev);
- }
- // else will return IN_PASS because we never used the button.
- }
-
+ // else will return IN_PASS because we never used the button.
return ret;
}
Index: source/gui/CInput.cpp
===================================================================
--- source/gui/CInput.cpp (revision 18090)
+++ source/gui/CInput.cpp (working copy)
@@ -95,7 +95,7 @@
{
ENSURE(m_iBufferPos != -1);
- if (ev->ev.type == SDL_HOTKEYDOWN)
+ if (ev->ev.type == SDL_HOTKEYUP)
{
if (m_ComposingText)
return IN_HANDLED;
@@ -181,6 +181,23 @@
return IN_HANDLED;
}
+ else if (ev->ev.type == SDL_KEYUP)
+ {
+ if (ev->ev.key.keysym.sym == SDLK_KP_ENTER || ev->ev.key.keysym.sym == SDLK_RETURN)
+ // 'Return' should do a Press event for single liners (e.g. submitting forms)
+ // otherwise a '\n' character will be added.
+ {
+ bool multiline;
+ GUI::GetSetting(this, "multiline", multiline);
+ if (!multiline)
+ {
+ SendEvent(GUIM_PRESSED, "press");
+ UpdateBufferPositionSetting();
+ return IN_HANDLED;
+ }
+
+ }
+ }
else if (ev->ev.type == SDL_KEYDOWN)
{
if (m_ComposingText)
@@ -474,13 +491,10 @@
{
bool multiline;
GUI::GetSetting(this, "multiline", multiline);
- if (!multiline)
+ if (multiline)
{
- SendEvent(GUIM_PRESSED, "press");
- break;
+ cooked = '\n'; // Change to '\n' and do default:
}
-
- cooked = '\n'; // Change to '\n' and do default:
// NOTE: Fall-through
}
default: // Insert a character