3 ms·
> When you call ImGui::Button("Hello World") it has no way of telling if it’s the same button as on the previous frame ImGui does have stable widget ids, other
by flohofwoe 6y ago
> When you call ImGui::Button("Hello World") it has no way of telling if it’s the same button as on the previous frame
ImGui does have stable widget ids, otherwise many features which require keeping state across frames wouldn't work. In case of your button example, the widget id is hashed from the label string "Hello World":
https://github.com/ocornut/imgui/blob/61b19489f1ba35934d9114c034b24eb5bff149e7/imgui_widgets.cpp#L673 https://github.com/ocornut/imgui/blob/61b19489f1ba35934d9114...
This is just the default behaviour, there's also a convention to define the id separately from the visible label string behind a '##':
https://github.com/ocornut/imgui/blob/61b19489f1ba35934d9114c034b24eb5bff149e7/imgui_demo.cpp#L1646 https://github.com/ocornut/imgui/blob/61b19489f1ba35934d9114...
Of course other immediate mode UIs might have a different way to define widget ids.