Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added set_keyboard_focus_here #38

Merged
merged 3 commits into from
Dec 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions example/example.script
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,9 @@ local function update_tab2(self)

imgui.separator()

if imgui.button("Push me to focus on test double") then
imgui.set_keyboard_focus_here(0)
end
local testdbl = self.testdbl or 0
local changed, value = imgui.input_double("test double", testdbl, 0.0001, 0.01, 5)
if changed then
Expand Down
8 changes: 8 additions & 0 deletions imgui/api/imgui.script_api
Original file line number Diff line number Diff line change
Expand Up @@ -1392,6 +1392,14 @@
- name: y
type: number

#*****************************************************************************************************

- name: set_keyboard_focus_here
type: function

parameters:
- name: offset
type: number

#*****************************************************************************************************
#***** STYLE *****************************************************************************************
Expand Down
10 changes: 10 additions & 0 deletions imgui/src/extension_imgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1642,6 +1642,15 @@ static int imgui_GetItemRectMax(lua_State* L)
return 2;
}

static int imgui_SetKeyboardFocusHere(lua_State* L)
{
DM_LUA_STACK_CHECK(L, 0);
imgui_NewFrame();
int offset = luaL_checknumber(L, 1);
ImGui::SetKeyboardFocusHere(offset);
return 0;
}

// ----------------------------
// ----- STYLE ----------------
// ----------------------------
Expand Down Expand Up @@ -2284,6 +2293,7 @@ static const luaL_reg Module_methods[] =
{"get_item_rect_max", imgui_GetItemRectMax},
{"is_mouse_clicked", imgui_IsMouseClicked},
{"is_mouse_double_clicked", imgui_IsMouseDoubleClicked},
{"set_keyboard_focus_here", imgui_SetKeyboardFocusHere},

{"set_style_window_rounding", imgui_SetStyleWindowRounding},
{"set_style_window_bordersize", imgui_SetStyleWindowBorderSize},
Expand Down