From 3dff5978a7a618eb964365a67d762bdfb93e4e9c Mon Sep 17 00:00:00 2001 From: Tony <546342@gmail.com> Date: Wed, 10 Apr 2024 13:33:13 +0700 Subject: [PATCH] Method selectable() now returns two values: the click flag and the actual value --- imgui/api/imgui.script_api | 2 ++ imgui/src/extension_imgui.cpp | 7 ++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/imgui/api/imgui.script_api b/imgui/api/imgui.script_api index ef4e780..0b2bc8e 100644 --- a/imgui/api/imgui.script_api +++ b/imgui/api/imgui.script_api @@ -965,6 +965,8 @@ optional: true return: + - name: clicked + type: boolean - name: selected type: boolean diff --git a/imgui/src/extension_imgui.cpp b/imgui/src/extension_imgui.cpp index dc5c430..ec29f68 100644 --- a/imgui/src/extension_imgui.cpp +++ b/imgui/src/extension_imgui.cpp @@ -1356,7 +1356,7 @@ static int imgui_SliderFloat(lua_State* L) static int imgui_Selectable(lua_State* L) { - DM_LUA_STACK_CHECK(L, 1); + DM_LUA_STACK_CHECK(L, 2); imgui_NewFrame(); const char* text = luaL_checkstring(L, 1); bool selected = lua_toboolean(L, 2); @@ -1371,9 +1371,10 @@ static int imgui_Selectable(lua_State* L) size.x = luaL_checknumber(L, 4); size.y = luaL_checknumber(L, 5); } - bool result = ImGui::Selectable(text, selected, flags, size); + bool result = ImGui::Selectable(text, &selected, flags, size); lua_pushboolean(L, result); - return 1; + lua_pushboolean(L, selected); + return 2; } static int imgui_SmallButton(lua_State* L)