Support events over multiple ImGui contexts

This commit is contained in:
Dan Paulat 2022-11-28 09:23:12 -06:00
parent f27e2534a7
commit fcb89926ca
2 changed files with 16 additions and 1 deletions

@ -1 +1 @@
Subproject commit 0ebc0fe7fa88aa3d1eb58b2f040f11ba45227829 Subproject commit a914f1811185f5959d50f2a199420dee4d15ae74

View file

@ -75,7 +75,22 @@ std::string ImGuiDebugWidget::context_name() const
void ImGuiDebugWidget::set_current_context(ImGuiContext* context) void ImGuiDebugWidget::set_current_context(ImGuiContext* context)
{ {
if (context == p->currentContext_)
{
return;
}
// Unregister widget with current context
ImGui::SetCurrentContext(p->currentContext_);
ImGui_ImplQt_UnregisterWidget(this);
p->currentContext_ = context; p->currentContext_ = context;
// Register widget with new context
ImGui::SetCurrentContext(context);
ImGui_ImplQt_RegisterWidget(this);
// Queue an update
update(); update();
} }