Centralize retained message dialog close callbacks

This commit is contained in:
2026-06-12 15:32:28 +02:00
parent d60f4d30e2
commit 14ccf67acd
5 changed files with 17 additions and 2 deletions

View File

@@ -82,4 +82,11 @@ void bind_legacy_click_destroys_node(ButtonT& button, Node& target) noexcept
};
}
inline std::function<void(Node*)> legacy_destroy_node_callback(Node& target)
{
return [&target](Node*) {
target.destroy();
};
}
} // namespace pp::panopainter

View File

@@ -1,5 +1,6 @@
#include "pch.h"
#include "log.h"
#include "legacy_ui_overlay_services.h"
#include "node_input_box.h"
#include "layout.h"
@@ -24,7 +25,7 @@ void NodeInputBox::init()
on_submit(this, m_field_text->m_text);
};
btn_cancel = find<NodeButton>("btn-cancel");
btn_cancel->on_click = [&](Node*) { destroy(); };
pp::panopainter::bind_legacy_click_destroys_node(*btn_cancel, *this);
m_capture_children = false; // don't capture children events on mouse_capture
}

View File

@@ -1,5 +1,6 @@
#include "pch.h"
#include "log.h"
#include "legacy_ui_overlay_services.h"
#include "node_message_box.h"
#include "layout.h"
@@ -23,7 +24,7 @@ void NodeMessageBox::init()
on_submit(this);
};
btn_cancel = find<NodeButton>("btn-cancel");
on_submit = btn_cancel->on_click = [&](Node*) { destroy(); };
on_submit = btn_cancel->on_click = pp::panopainter::legacy_destroy_node_callback(*this);
m_capture_children = false; // don't capture children events on mouse_capture
}