首页 > 代码库 > libsdl中文输入法候选列表不显示解决方案

libsdl中文输入法候选列表不显示解决方案

libsdl输入中文时输入法不显示,将WM_IME_SETCONTEXT事件处理给注释即可。

WM_IME_SETCONTEXT

If the application draws the composition window, the default IME window does not have to show its composition window. In this case, the application must clear the ISC_SHOWUICOMPOSITIONWINDOW value from the lParam parameter before passing the message to DefWindowProc or ImmIsUIMessage. To display a certain user interface window, an application should remove the corresponding value so that the IME will not display it.

修改SDL_windowskeyboard.c找到IME_HandleMessage函数改为以下代码即可。

SDL_boolIME_HandleMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM *lParam, SDL_VideoData *videodata){    SDL_bool trap = SDL_FALSE;    HIMC himc = 0;    if (!videodata->ime_initialized || !videodata->ime_available || !videodata->ime_enabled)        return SDL_FALSE;    switch (msg) {    case WM_INPUTLANGCHANGE:        IME_InputLangChanged(videodata);        break;    //输入法候选框不显示    //case WM_IME_SETCONTEXT:    //    *lParam = 0;    //    break;    case WM_IME_STARTCOMPOSITION:        trap = SDL_TRUE;        break;    case WM_IME_COMPOSITION:        trap = SDL_TRUE;        himc = ImmGetContext(hwnd);        if (*lParam & GCS_RESULTSTR) {            IME_GetCompositionString(videodata, himc, GCS_RESULTSTR);            IME_SendInputEvent(videodata);        }        if (*lParam & GCS_COMPSTR) {            if (!videodata->ime_uiless)                videodata->ime_readingstring[0] = 0;            IME_GetCompositionString(videodata, himc, GCS_COMPSTR);            IME_SendEditingEvent(videodata);        }        ImmReleaseContext(hwnd, himc);        break;    case WM_IME_ENDCOMPOSITION:        videodata->ime_composition[0] = 0;        videodata->ime_readingstring[0] = 0;        videodata->ime_cursor = 0;        SDL_SendEditingText("", 0, 0);        break;    case WM_IME_NOTIFY:        switch (wParam) {        case IMN_SETCONVERSIONMODE:        case IMN_SETOPENSTATUS:            IME_UpdateInputLocale(videodata);            break;        case IMN_OPENCANDIDATE:        case IMN_CHANGECANDIDATE:            if (videodata->ime_uiless)                break;            trap = SDL_TRUE;            IME_ShowCandidateList(videodata);            himc = ImmGetContext(hwnd);            if (!himc)                break;            IME_GetCandidateList(himc, videodata);            ImmReleaseContext(hwnd, himc);            break;        case IMN_CLOSECANDIDATE:            trap = SDL_TRUE;            IME_HideCandidateList(videodata);            break;        case IMN_PRIVATE:            {                DWORD dwId = IME_GetId(videodata, 0);                IME_GetReadingString(videodata, hwnd);                switch (dwId)                {                case IMEID_CHT_VER42:                case IMEID_CHT_VER43:                case IMEID_CHT_VER44:                case IMEID_CHS_VER41:                case IMEID_CHS_VER42:                    if (*lParam == 1 || *lParam == 2)                        trap = SDL_TRUE;                    break;                case IMEID_CHT_VER50:                case IMEID_CHT_VER51:                case IMEID_CHT_VER52:                case IMEID_CHT_VER60:                case IMEID_CHS_VER53:                    if (*lParam == 16                        || *lParam == 17                        || *lParam == 26                        || *lParam == 27                        || *lParam == 28)                        trap = SDL_TRUE;                    break;                }            }            break;        default:            trap = SDL_TRUE;            break;        }        break;    }    return trap;}

  

libsdl中文输入法候选列表不显示解决方案