mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-31 07:37:24 +00:00
Associate PopupWindow
s with an ID for their active popup (#6693)
Popups are stored in a HashMap and are assigned an ID so popup.close(); closes the correct popup and so a single PopupWindow cannot be opened multiple times
This commit is contained in:
parent
d30dfc0175
commit
6da0f55b05
11 changed files with 459 additions and 74 deletions
|
@ -106,18 +106,23 @@ public:
|
|||
}
|
||||
|
||||
template<typename Component, typename Parent, typename PosGetter>
|
||||
void show_popup(const Parent *parent_component, PosGetter pos,
|
||||
cbindgen_private::PopupClosePolicy close_policy,
|
||||
cbindgen_private::ItemRc parent_item) const
|
||||
uint32_t show_popup(const Parent *parent_component, PosGetter pos,
|
||||
cbindgen_private::PopupClosePolicy close_policy,
|
||||
cbindgen_private::ItemRc parent_item) const
|
||||
{
|
||||
auto popup = Component::create(parent_component);
|
||||
cbindgen_private::Point p = pos(popup);
|
||||
auto popup_dyn = popup.into_dyn();
|
||||
cbindgen_private::slint_windowrc_show_popup(&inner, &popup_dyn, p, close_policy,
|
||||
&parent_item);
|
||||
return cbindgen_private::slint_windowrc_show_popup(&inner, &popup_dyn, p, close_policy,
|
||||
&parent_item);
|
||||
}
|
||||
|
||||
void close_popup() const { cbindgen_private::slint_windowrc_close_popup(&inner); }
|
||||
void close_popup(uint32_t popup_id) const
|
||||
{
|
||||
if (popup_id > 0) {
|
||||
cbindgen_private::slint_windowrc_close_popup(&inner, popup_id);
|
||||
}
|
||||
}
|
||||
|
||||
template<std::invocable<RenderingState, GraphicsAPI> F>
|
||||
std::optional<SetRenderingNotifierError> set_rendering_notifier(F callback) const
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue