Ticket #3870: keyfixv3.patch

File keyfixv3.patch, 3.0 KB (added by Imarok, 8 years ago)

Now the chat message gets sent

  • 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_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) )
    6978    {
     79        ret = GetFocusedObject()->ManuallyHandleEvent(ev);
     80    }
     81
     82    else if (ev->ev.type == SDL_HOTKEYUP)
     83    {
    7084        const char* hotkey = static_cast<const char*>(ev->ev.user.data1);
    7185        std::map<CStr, std::vector<IGUIObject*> >::iterator it = m_HotkeyObjects.find(hotkey);
    7286        if (it != m_HotkeyObjects.end())
     
    243257        m_MousePos = oldMousePos;
    244258    }
    245259
    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.
    263261    return ret;
    264262}
    265263
  • 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            }
    482 
    483             cooked = '\n'; // Change to '\n' and do default:
    484498            // NOTE: Fall-through
    485499        }
    486500        default: // Insert a character