Added in explicit touchscreen keyboard support. (#1389)
This commit is contained in:
parent
86fa90a76b
commit
1a0d3a4a03
|
@ -84,6 +84,11 @@ function CommandView:get_line_screen_position(line, col)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function CommandView:supports_text_input()
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
function CommandView:get_scrollable_size()
|
function CommandView:get_scrollable_size()
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
|
|
|
@ -252,6 +252,11 @@ function DocView:scroll_to_line(line, ignore_if_visible, instant)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function DocView:supports_text_input()
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
function DocView:scroll_to_make_visible(line, col)
|
function DocView:scroll_to_make_visible(line, col)
|
||||||
local ox, oy = self:get_content_offset()
|
local ox, oy = self:get_content_offset()
|
||||||
local _, ly = self:get_line_screen_position(line, col)
|
local _, ly = self:get_line_screen_position(line, col)
|
||||||
|
|
|
@ -1105,6 +1105,7 @@ function core.set_active_view(view)
|
||||||
-- Reset the IME even if the focus didn't change
|
-- Reset the IME even if the focus didn't change
|
||||||
ime.stop()
|
ime.stop()
|
||||||
if view ~= core.active_view then
|
if view ~= core.active_view then
|
||||||
|
system.text_input(view:supports_text_input())
|
||||||
if core.active_view and core.active_view.force_focus then
|
if core.active_view and core.active_view.force_focus then
|
||||||
core.next_active_view = view
|
core.next_active_view = view
|
||||||
return
|
return
|
||||||
|
|
|
@ -108,6 +108,10 @@ function View:get_h_scrollable_size()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function View:supports_text_input()
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
---@param x number
|
---@param x number
|
||||||
---@param y number
|
---@param y number
|
||||||
---@return boolean
|
---@return boolean
|
||||||
|
|
|
@ -966,7 +966,7 @@ static int f_library_gc(lua_State *L) {
|
||||||
lua_getfield(L, 1, "handle");
|
lua_getfield(L, 1, "handle");
|
||||||
void* handle = lua_touserdata(L, -1);
|
void* handle = lua_touserdata(L, -1);
|
||||||
SDL_UnloadObject(handle);
|
SDL_UnloadObject(handle);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1069,6 +1069,15 @@ static int f_path_compare(lua_State *L) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int f_text_input(lua_State* L) {
|
||||||
|
if (lua_toboolean(L, 1))
|
||||||
|
SDL_StartTextInput();
|
||||||
|
else
|
||||||
|
SDL_StopTextInput();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static const luaL_Reg lib[] = {
|
static const luaL_Reg lib[] = {
|
||||||
{ "poll_event", f_poll_event },
|
{ "poll_event", f_poll_event },
|
||||||
{ "wait_event", f_wait_event },
|
{ "wait_event", f_wait_event },
|
||||||
|
@ -1102,12 +1111,13 @@ static const luaL_Reg lib[] = {
|
||||||
{ "load_native_plugin", f_load_native_plugin },
|
{ "load_native_plugin", f_load_native_plugin },
|
||||||
{ "path_compare", f_path_compare },
|
{ "path_compare", f_path_compare },
|
||||||
{ "get_fs_type", f_get_fs_type },
|
{ "get_fs_type", f_get_fs_type },
|
||||||
|
{ "text_input", f_text_input },
|
||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
int luaopen_system(lua_State *L) {
|
int luaopen_system(lua_State *L) {
|
||||||
luaL_newmetatable(L, API_TYPE_NATIVE_PLUGIN);
|
luaL_newmetatable(L, API_TYPE_NATIVE_PLUGIN);
|
||||||
lua_pushcfunction(L, f_library_gc);
|
lua_pushcfunction(L, f_library_gc);
|
||||||
lua_setfield(L, -2, "__gc");
|
lua_setfield(L, -2, "__gc");
|
||||||
luaL_newlib(L, lib);
|
luaL_newlib(L, lib);
|
||||||
|
|
|
@ -212,6 +212,8 @@ init_lua:
|
||||||
set_macos_bundle_resources(L);
|
set_macos_bundle_resources(L);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
SDL_EventState(SDL_TEXTINPUT, SDL_ENABLE);
|
||||||
|
SDL_EventState(SDL_TEXTEDITING, SDL_ENABLE);
|
||||||
|
|
||||||
const char *init_lite_code = \
|
const char *init_lite_code = \
|
||||||
"local core\n"
|
"local core\n"
|
||||||
|
|
Loading…
Reference in New Issue