This commit is contained in:
Camilla Löwy 2024-02-16 13:57:18 +01:00
parent c8372cda08
commit 7bdcdf435a
2 changed files with 9 additions and 15 deletions

View File

@ -494,6 +494,7 @@ GLFWAPI void glfwDestroyWindow(GLFWwindow* handle)
*prev = window->next; *prev = window->next;
} }
_glfw_free(window->title); _glfw_free(window->title);
_glfw_free(window); _glfw_free(window);
} }

View File

@ -110,9 +110,6 @@ int main(int argc, char** argv)
nk_glfw3_font_stash_begin(&atlas); nk_glfw3_font_stash_begin(&atlas);
nk_glfw3_font_stash_end(); nk_glfw3_font_stash_end();
// test setting title with result from glfwGetWindowTitle
glfwSetWindowTitle(window, glfwGetWindowTitle(window));
strncpy(window_title, glfwGetWindowTitle(window), sizeof(window_title)); strncpy(window_title, glfwGetWindowTitle(window), sizeof(window_title));
while (!(may_close && glfwWindowShouldClose(window))) while (!(may_close && glfwWindowShouldClose(window)))
@ -194,24 +191,20 @@ int main(int argc, char** argv)
nk_label(nk, "Press Enter in a text field to set value", NK_TEXT_CENTERED); nk_label(nk, "Press Enter in a text field to set value", NK_TEXT_CENTERED);
nk_flags events; nk_flags events;
const nk_flags flags = NK_EDIT_FIELD | const nk_flags flags = NK_EDIT_FIELD |
NK_EDIT_SIG_ENTER | NK_EDIT_SIG_ENTER |
NK_EDIT_GOTO_END_ON_ACTIVATE; NK_EDIT_GOTO_END_ON_ACTIVATE;
nk_layout_row_dynamic(nk, 30, 2); nk_layout_row_begin(nk, NK_DYNAMIC, 30, 2);
nk_label(nk, "Window Title:", NK_TEXT_LEFT); nk_layout_row_push(nk, 1.f / 3.f);
nk_label(nk, "Title", NK_TEXT_LEFT);
events = nk_edit_string_zero_terminated( nk, flags, window_title, sizeof(window_title), NULL ); nk_layout_row_push(nk, 2.f / 3.f);
events = nk_edit_string_zero_terminated(nk, flags, window_title,
sizeof(window_title), NULL);
if (events & NK_EDIT_COMMITED) if (events & NK_EDIT_COMMITED)
{
glfwSetWindowTitle(window, window_title); glfwSetWindowTitle(window, window_title);
// we do not need to call glfwGetWindowTitle as we already store the title, but using it here for testing purposes nk_layout_row_end(nk);
strncpy( window_title, glfwGetWindowTitle(window), sizeof(window_title));
}
if (position_supported) if (position_supported)
{ {