Skip to content

Commit

Permalink
Method selectable() now returns two values: the click flag and the ac…
Browse files Browse the repository at this point in the history
…tual value
  • Loading branch information
u546342 committed Apr 10, 2024
1 parent 657bdba commit 3dff597
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 2 additions & 0 deletions imgui/api/imgui.script_api
Original file line number Diff line number Diff line change
Expand Up @@ -965,6 +965,8 @@
optional: true

return:
- name: clicked
type: boolean
- name: selected
type: boolean

Expand Down
7 changes: 4 additions & 3 deletions imgui/src/extension_imgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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)
Expand Down

0 comments on commit 3dff597

Please sign in to comment.