Ticket #3870: keyfixv5.patch
File keyfixv5.patch, 6.5 KB (added by , 8 years ago) |
---|
-
binaries/data/mods/public/gui/session/hotkeys/misc.xml
4 4 <action on="Press">closeOpenDialogs();</action> 5 5 </object> 6 6 7 <!-- Chat: Depending on the current state, it either opens message window or closes message window / posts message-->7 <!-- Chat: Depending on the current state, it opens the message window. --> 8 8 <object hotkey="chat"> 9 <action on="Press"> toggleChatWindow();</action>9 <action on="Press">openChatWindow();</action> 10 10 </object> 11 11 12 12 <!-- Team Chat: Does the same as the above, but sets the window up to only send messages to teammates. --> 13 13 <object hotkey="teamchat"> 14 <action on="Press"> toggleChatWindow(true);</action>14 <action on="Press">openChatWindow(true);</action> 15 15 </object> 16 16 17 17 <!-- Menu --> -
binaries/data/mods/public/gui/session/menu.js
86 86 87 87 function chatMenuButton() 88 88 { 89 close OpenDialogs();90 openChat ();89 closeMenu(); 90 openChatWindow(); 91 91 } 92 92 93 93 function diplomacyMenuButton() … … 196 196 Engine.PushGuiPage("page_options.xml", { "callback": "resumeGame" }); 197 197 } 198 198 199 function openChat()200 {201 if (g_Disconnected)202 return;203 204 closeOpenDialogs();205 206 setTeamChat(false);207 208 Engine.GetGUIObjectByName("chatInput").focus(); // Grant focus to the input area209 Engine.GetGUIObjectByName("chatDialogPanel").hidden = false;210 }211 212 199 function closeChat() 213 200 { 214 Engine.GetGUIObjectByName("chatInput").caption = ""; // Clear chat input 215 Engine.GetGUIObjectByName("chatInput").blur(); // Remove focus 216 Engine.GetGUIObjectByName("chatDialogPanel").hidden = true; 201 let chatWindow = Engine.GetGUIObjectByName("chatDialogPanel"); 202 if(!chatWindow.hidden) 203 { 204 Engine.GetGUIObjectByName("chatInput").caption = ""; // Clear chat input 205 Engine.GetGUIObjectByName("chatInput").blur(); // Remove focus 206 chatWindow.hidden = true; 207 } 217 208 } 218 209 219 210 /** … … 228 219 } 229 220 230 221 /** 231 * Opens chat-window or closes it and sends the userinput.222 * Opens or focuses chat-window. 232 223 */ 233 function toggleChatWindow(teamChat)224 function openChatWindow(teamChat) 234 225 { 235 226 if (g_Disconnected) 236 227 return; … … 237 228 238 229 let chatWindow = Engine.GetGUIObjectByName("chatDialogPanel"); 239 230 let chatInput = Engine.GetGUIObjectByName("chatInput"); 240 let hidden = chatWindow.hidden; 241 242 closeOpenDialogs(); 243 244 if (hidden) 231 if(!chatWindow.hidden) 245 232 { 246 setTeamChat(teamChat);247 233 chatInput.focus(); 234 return; 248 235 } 249 else250 {251 if (chatInput.caption.length)252 {253 submitChatInput();254 return;255 }256 chatInput.caption = "";257 }258 236 259 chatWindow.hidden = !hidden; 237 closeOpenDialogs(); 238 setTeamChat(teamChat); 239 chatInput.focus(); 240 241 chatWindow.hidden = false; 260 242 } 261 243 262 244 function openDiplomacy() -
binaries/data/mods/public/gui/session/messages.js
574 574 let input = Engine.GetGUIObjectByName("chatInput"); 575 575 let text = input.caption; 576 576 577 input.blur(); // Remove focus 578 input.caption = ""; // Clear chat input 579 toggleChatWindow(); 577 closeChat(); 580 578 581 579 if (!text.length) 582 580 return; -
source/gui/CGUI.cpp
65 65 { 66 66 InReaction ret = IN_PASS; 67 67 68 if (ev->ev.type == SDL_HOTKEYDOWN) 68 // Handle keys for input boxes 69 if ( GetFocusedObject() && 70 ((ev->ev.type == SDL_KEYDOWN && 71 ev->ev.key.keysym.sym != SDLK_ESCAPE && 72 !g_keys[SDLK_LCTRL] && !g_keys[SDLK_RCTRL] && 73 !g_keys[SDLK_LALT] && !g_keys[SDLK_RALT]) || 74 ev->ev.type == SDL_HOTKEYDOWN || ev->ev.type == SDL_HOTKEYUP || 75 (ev->ev.type == SDL_KEYUP && (ev->ev.key.keysym.sym == SDLK_KP_ENTER || ev->ev.key.keysym.sym == SDLK_RETURN)) || 76 ev->ev.type == SDL_TEXTINPUT || 77 ev->ev.type == SDL_TEXTEDITING) ) 69 78 { 79 ret = GetFocusedObject()->ManuallyHandleEvent(ev); 80 } 81 82 else if (ev->ev.type == SDL_HOTKEYUP) 83 { 70 84 const char* hotkey = static_cast<const char*>(ev->ev.user.data1); 71 85 std::map<CStr, std::vector<IGUIObject*> >::iterator it = m_HotkeyObjects.find(hotkey); 72 86 if (it != m_HotkeyObjects.end()) … … 243 257 m_MousePos = oldMousePos; 244 258 } 245 259 246 // Handle keys for input boxes 247 if (GetFocusedObject()) 248 { 249 if ( 250 (ev->ev.type == SDL_KEYDOWN && 251 ev->ev.key.keysym.sym != SDLK_ESCAPE && 252 !g_keys[SDLK_LCTRL] && !g_keys[SDLK_RCTRL] && 253 !g_keys[SDLK_LALT] && !g_keys[SDLK_RALT]) 254 || ev->ev.type == SDL_HOTKEYDOWN 255 || ev->ev.type == SDL_TEXTINPUT || ev->ev.type == SDL_TEXTEDITING 256 ) 257 { 258 ret = GetFocusedObject()->ManuallyHandleEvent(ev); 259 } 260 // else will return IN_PASS because we never used the button. 261 } 262 260 // else will return IN_PASS because we never used the button. 263 261 return ret; 264 262 } 265 263 -
source/gui/CInput.cpp
95 95 { 96 96 ENSURE(m_iBufferPos != -1); 97 97 98 if (ev->ev.type == SDL_HOTKEY DOWN)98 if (ev->ev.type == SDL_HOTKEYUP) 99 99 { 100 100 if (m_ComposingText) 101 101 return IN_HANDLED; … … 181 181 182 182 return IN_HANDLED; 183 183 } 184 else if (ev->ev.type == SDL_KEYUP) 185 { 186 if (ev->ev.key.keysym.sym == SDLK_KP_ENTER || ev->ev.key.keysym.sym == SDLK_RETURN) 187 // 'Return' should do a Press event for single liners (e.g. submitting forms) 188 // otherwise a '\n' character will be added. 189 { 190 bool multiline; 191 GUI<bool>::GetSetting(this, "multiline", multiline); 192 if (!multiline) 193 { 194 SendEvent(GUIM_PRESSED, "press"); 195 UpdateBufferPositionSetting(); 196 return IN_HANDLED; 197 } 198 199 } 200 } 184 201 else if (ev->ev.type == SDL_KEYDOWN) 185 202 { 186 203 if (m_ComposingText) … … 474 491 { 475 492 bool multiline; 476 493 GUI<bool>::GetSetting(this, "multiline", multiline); 477 if ( !multiline)494 if (multiline) 478 495 { 479 SendEvent(GUIM_PRESSED, "press"); 480 break; 496 cooked = '\n'; // Change to '\n' and do default: 481 497 } 482 483 cooked = '\n'; // Change to '\n' and do default:484 498 // NOTE: Fall-through 485 499 } 486 500 default: // Insert a character