Skip to content

Commit

Permalink
Add ImGui Text Input
Browse files Browse the repository at this point in the history
  • Loading branch information
HerrNamenlos123 committed Aug 14, 2024
1 parent 655eaf7 commit 383a508
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/core/src/imguilua.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ extern "C" {
}

#include <LuaBridge/LuaBridge.h>
#include <LuaBridge/detail/FuncTraits.h>
#include <LuaBridge/detail/Stack.h>

#define ADD_IMGUI_FUNCTION(name) addFunction(#name, &ImGui::name)
Expand Down Expand Up @@ -563,6 +564,20 @@ void ImGuiLua::DeclareLuaBridge(lua_State* L)
return Spinner(label.c_str(), radius, thickness, color);
});

ns.addFunction("InputText",
[](const std::string& name,
const std::string& value,
luabridge::LuaRef setValue) {
std::string buffer = value;
buffer.resize(128, '\0');
ImGui::InputText(name.c_str(),
const_cast<char*>(buffer.data()),
buffer.size());
if (std::string(buffer.c_str()) != value) {
setValue(std::string(buffer.c_str()));
}
});

ns.ADD_FUNCTION(Text);
ns.ADD_FUNCTION(Button);

Expand Down

0 comments on commit 383a508

Please sign in to comment.