Add IME support (#991)
This commit is contained in:
@@ -249,6 +249,23 @@ top:
|
||||
lua_pushstring(L, e.text.text);
|
||||
return 2;
|
||||
|
||||
case SDL_TEXTEDITING:
|
||||
lua_pushstring(L, "textediting");
|
||||
lua_pushstring(L, e.edit.text);
|
||||
lua_pushinteger(L, e.edit.start);
|
||||
lua_pushinteger(L, e.edit.length);
|
||||
return 4;
|
||||
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 22)
|
||||
case SDL_TEXTEDITING_EXT:
|
||||
lua_pushstring(L, "textediting");
|
||||
lua_pushstring(L, e.editExt.text);
|
||||
lua_pushinteger(L, e.editExt.start);
|
||||
lua_pushinteger(L, e.editExt.length);
|
||||
SDL_free(e.editExt.text);
|
||||
return 4;
|
||||
#endif
|
||||
|
||||
case SDL_MOUSEBUTTONDOWN:
|
||||
if (e.button.button == 1) { SDL_CaptureMouse(1); }
|
||||
lua_pushstring(L, "mousepressed");
|
||||
@@ -425,6 +442,23 @@ static int f_get_window_mode(lua_State *L) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int f_set_text_input_rect(lua_State *L) {
|
||||
SDL_Rect rect;
|
||||
rect.x = luaL_checknumber(L, 1);
|
||||
rect.y = luaL_checknumber(L, 2);
|
||||
rect.w = luaL_checknumber(L, 3);
|
||||
rect.h = luaL_checknumber(L, 4);
|
||||
SDL_SetTextInputRect(&rect);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int f_clear_ime(lua_State *L) {
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 22)
|
||||
SDL_ClearComposition();
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int f_raise_window(lua_State *L) {
|
||||
/*
|
||||
@@ -986,6 +1020,8 @@ static const luaL_Reg lib[] = {
|
||||
{ "set_window_hit_test", f_set_window_hit_test },
|
||||
{ "get_window_size", f_get_window_size },
|
||||
{ "set_window_size", f_set_window_size },
|
||||
{ "set_text_input_rect", f_set_text_input_rect },
|
||||
{ "clear_ime", f_clear_ime },
|
||||
{ "window_has_focus", f_window_has_focus },
|
||||
{ "raise_window", f_raise_window },
|
||||
{ "show_fatal_error", f_show_fatal_error },
|
||||
|
||||
@@ -133,6 +133,12 @@ int main(int argc, char **argv) {
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 5)
|
||||
SDL_SetHint(SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH, "1");
|
||||
#endif
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 18)
|
||||
SDL_SetHint(SDL_HINT_IME_SHOW_UI, "1");
|
||||
#endif
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 22)
|
||||
SDL_SetHint(SDL_HINT_IME_SUPPORT_EXTENDED_TEXT, "1");
|
||||
#endif
|
||||
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 8)
|
||||
/* This hint tells SDL to respect borderless window as a normal window.
|
||||
|
||||
Reference in New Issue
Block a user