IME Candidates not showing?


#1

Hello, I’m making a game with in-game chat function

When I use Japanese / Chinese input method

I can get input texts, but I can’t get the candidate window show up

normally it should be look like this
image

searched “SDL IME” but no luck

is there any documentation about how it work?


My code:

SDL_Rect aa;
aa.x = 200; aa.y = 00; aa.w = 200; aa.h = 24;

SDL_StartTextInput();

//Event handler
SDL_Event e;
bool quit = false;

while (!quit) {
	while (SDL_PollEvent(&e) != 0)
	{
		if (e.type == SDL_QUIT)
		{
			quit = true;
		}
		else if (e.type == SDL_TEXTINPUT)
		{
			//Not copy or pasting
			if (!((e.text.text[0] == 'c' || e.text.text[0] == 'C') && (e.text.text[0] == 'v' || e.text.text[0] == 'V') && SDL_GetModState() & KMOD_CTRL))
			{
				printf(e.text.text);
			}
		}
	}
	SDL_SetTextInputRect(&aa);
	//Update the surface
	SDL_UpdateWindowSurface(window);

	SDL_Delay(10);
}

Windows 10 x64 / SDL 2.0.8 / VS 2015


#2

sorry to ressurect old topic,
i am having exactly the same problem.
window with IME candidates in not showing for me.
This is my simple sample code, mostly taken from
https://wiki.libsdl.org/Tutorials/TextInput

int main(int argc, char* argv[])
{
	auto utf8_decode = [](const std::string &str) -> std::wstring
	{
		if (str.empty()) return std::wstring();
		int size_needed = MultiByteToWideChar(CP_UTF8, 0, &str[0], (int)str.size(), NULL, 0);
		std::wstring wstrTo(size_needed, 0);
		MultiByteToWideChar(CP_UTF8, 0, &str[0], (int)str.size(), &wstrTo[0], size_needed);
		return wstrTo;
	};

	SDL_bool done = SDL_FALSE;

	SDL_Window* window = SDL_CreateWindow( "hello_sdl2", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 800, 600, SDL_WINDOW_SHOWN );

    SDL_Rect r;
	r.x = 0;
	r.y = 0;
	SDL_SetTextInputRect(&r);
	SDL_StartTextInput();
	while (!done) {
		SDL_Event event;
		if (SDL_PollEvent(&event)) {
			case SDL_QUIT:
				/* Quit */
				done = SDL_TRUE;
				break;
			case SDL_TEXTINPUT:
				{
				/* Add new text onto the end of our text */
				std::string utf8str(event.text.text);
				std::wstring utf16str = utf8_decode(utf8str);
				OutputDebugStringW(utf16str.c_str());
				break;
				}
			case SDL_TEXTEDITING:
				break;
			}
		}
	}

    SDL_StopTextInput();
	SDL_Quit();

	return 0;
}

I also tested setting different positions for SDL_SetTextInputRect() but none of them worked for me.
I am using SDL 2.0.9


#3

I am using SDL 2.0.9 on Windows10 x64 with VS2017.
The traditional desktop IME works well with SDL 2.0.9.
But some new IME,such as some Windows10 built-in IME,doesn’t show the candidates or even no response.