Ticket #3870: keyfixv2.patch

File keyfixv2.patch, 3.5 KB (added by Imarok, 8 years ago)

fixes #3870 but the inserted tchat text doesn't get sended anymore

  • binaries/data/mods/public/gui/credits/texts/programming.json

     
    8383            {"nick": "h20", "name": "Daniel Wilhelm"},
    8484            {"nick": "historic_bruno", "name": "Ben Brian"},
    8585            {"nick": "idanwin"},
     86            {"nick": "Imarok", "name": "J. S."},
    8687            {"nick": "infyquest", "name": "Vijay Kiran Kamuju"},
    8788            {"nick": "IronNerd", "name": "Matthew McMullan"},
    8889            {"nick": "Itms", "name": "Nicolas Auvray"},
  • source/gui/CGUI.cpp

     
    6565{
    6666    InReaction ret = IN_PASS;
    6767
    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 ||
     75            ev->ev.type == SDL_TEXTINPUT ||
     76            ev->ev.type == SDL_TEXTEDITING) )
    6977    {
     78        ret = GetFocusedObject()->ManuallyHandleEvent(ev);
     79    }
     80
     81    else if (ev->ev.type == SDL_HOTKEYUP)
     82    {
    7083        const char* hotkey = static_cast<const char*>(ev->ev.user.data1);
    7184        std::map<CStr, std::vector<IGUIObject*> >::iterator it = m_HotkeyObjects.find(hotkey);
    7285        if (it != m_HotkeyObjects.end())
     
    243256        m_MousePos = oldMousePos;
    244257    }
    245258
    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 
     259    // else will return IN_PASS because we never used the button.
    263260    return ret;
    264261}
    265262
  • source/gui/CInput.cpp

     
    9595{
    9696    ENSURE(m_iBufferPos != -1);
    9797
    98     if (ev->ev.type == SDL_HOTKEYDOWN)
     98    if (ev->ev.type == SDL_HOTKEYUP)
    9999    {
    100100        if (m_ComposingText)
    101101            return IN_HANDLED;
     
    181181
    182182        return IN_HANDLED;
    183183    }
     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    }
    184201    else if (ev->ev.type == SDL_KEYDOWN)
    185202    {
    186203        if (m_ComposingText)
     
    474491        {
    475492            bool multiline;
    476493            GUI<bool>::GetSetting(this, "multiline", multiline);
    477             if (!multiline)
     494            if (multiline)
    478495            {
    479                 SendEvent(GUIM_PRESSED, "press");
    480                 break;
     496                cooked = '\n'; // Change to '\n' and do default:
    481497            }
    482498
    483             cooked = '\n'; // Change to '\n' and do default:
     499           
    484500            // NOTE: Fall-through
    485501        }
    486502        default: // Insert a character