From 9fc327caa08b079e943379e666c62c4c49436885 Mon Sep 17 00:00:00 2001 From: Mikulas Florek Date: Mon, 11 Sep 2023 11:16:44 +0200 Subject: [PATCH] improved lua console --- data/editor/scripts/plugins/lua_console.lua | 1 + data/editor/scripts/plugins/lua_type_defs.lua | 1 + data/scripts/lumix.d.lua | 1 + src/engine/lua_api.cpp | 1 + 4 files changed, 4 insertions(+) diff --git a/data/editor/scripts/plugins/lua_console.lua b/data/editor/scripts/plugins/lua_console.lua index 7418255453..97a82a76b8 100644 --- a/data/editor/scripts/plugins/lua_console.lua +++ b/data/editor/scripts/plugins/lua_console.lua @@ -104,6 +104,7 @@ plugin.gui = function() if ImGui.IsKeyPressed(ImGui.Key_DownArrow, true) then autocomplete_selected_idx += 1 end if autocomplete_selected_idx < -1 then autocomplete_selected_idx = 0 end if autocomplete_selected_idx >= #suggestions then autocomplete_selected_idx = #suggestions - 1 end + if ImGui.IsKeyPressed(ImGui.Key_Escape, false) then ImGui.CloseCurrentPopup() end if ImGui.IsKeyPressed(ImGui.Key_Enter, false) then ImGui.CloseCurrentPopup() local k = suggestions[autocomplete_selected_idx + 1] diff --git a/data/editor/scripts/plugins/lua_type_defs.lua b/data/editor/scripts/plugins/lua_type_defs.lua index 9e8bec3d49..80896a51df 100644 --- a/data/editor/scripts/plugins/lua_type_defs.lua +++ b/data/editor/scripts/plugins/lua_type_defs.lua @@ -60,6 +60,7 @@ declare ImGui: { Key_DownArrow : number, Key_Enter : number, + Key_Escape : number, Key_UpArrow : number } diff --git a/data/scripts/lumix.d.lua b/data/scripts/lumix.d.lua index 859b270e56..144399dd19 100644 --- a/data/scripts/lumix.d.lua +++ b/data/scripts/lumix.d.lua @@ -59,6 +59,7 @@ declare ImGui: { Key_DownArrow : number, Key_Enter : number, + Key_Escape : number, Key_UpArrow : number } diff --git a/src/engine/lua_api.cpp b/src/engine/lua_api.cpp index 14d2d55cb2..1b1d946300 100644 --- a/src/engine/lua_api.cpp +++ b/src/engine/lua_api.cpp @@ -949,6 +949,7 @@ void registerEngineAPI(lua_State* L, Engine* engine) LuaWrapper::createSystemVariable(L, "ImGui", "StyleVar_WindowPadding", ImGuiStyleVar_WindowPadding); LuaWrapper::createSystemVariable(L, "ImGui", "Key_DownArrow", ImGuiKey_DownArrow); LuaWrapper::createSystemVariable(L, "ImGui", "Key_Enter", ImGuiKey_Enter); + LuaWrapper::createSystemVariable(L, "ImGui", "Key_Escape", ImGuiKey_Escape); LuaWrapper::createSystemVariable(L, "ImGui", "Key_UpArrow", ImGuiKey_UpArrow); LuaImGui::registerCFunction(L, "AlignTextToFramePadding", &LuaWrapper::wrap); LuaImGui::registerCFunction(L, "Begin", &LuaImGui::Begin);