mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-04 10:50:00 +00:00
Add support for manually closing PopupWindows
This patch adds a `close()` function that can be called to close a popup window, and a `close-to-click` boolean that can be set to false to disable the default behavior.
This commit is contained in:
parent
a0a5294e49
commit
0f54b9599b
20 changed files with 349 additions and 24 deletions
|
@ -2744,7 +2744,7 @@ fn compile_builtin_function_call(
|
|||
format!("{}.text_input_focused()", access_window_field(ctx))
|
||||
}
|
||||
BuiltinFunction::ShowPopupWindow => {
|
||||
if let [llr::Expression::NumberLiteral(popup_index), x, y, llr::Expression::PropertyReference(parent_ref)] =
|
||||
if let [llr::Expression::NumberLiteral(popup_index), x, y, close_on_click, llr::Expression::PropertyReference(parent_ref)] =
|
||||
arguments
|
||||
{
|
||||
let mut parent_ctx = ctx;
|
||||
|
@ -2764,13 +2764,18 @@ fn compile_builtin_function_call(
|
|||
let parent_component = access_item_rc(parent_ref, ctx);
|
||||
let x = compile_expression(x, ctx);
|
||||
let y = compile_expression(y, ctx);
|
||||
let close_on_click = compile_expression(close_on_click, ctx);
|
||||
format!(
|
||||
"{window}.show_popup<{popup_window_id}>({component_access}, {{ static_cast<float>({x}), static_cast<float>({y}) }}, {{ {parent_component} }})"
|
||||
"{window}.show_popup<{popup_window_id}>({component_access}, {{ static_cast<float>({x}), static_cast<float>({y}) }}, {close_on_click}, {{ {parent_component} }})"
|
||||
)
|
||||
} else {
|
||||
panic!("internal error: invalid args to ShowPopupWindow {:?}", arguments)
|
||||
}
|
||||
}
|
||||
BuiltinFunction::ClosePopupWindow => {
|
||||
let window = access_window_field(ctx);
|
||||
format!("{window}.close_popup()")
|
||||
}
|
||||
BuiltinFunction::ItemMemberFunction(name) => {
|
||||
if let [llr::Expression::PropertyReference(pr)] = arguments {
|
||||
let item = access_member(pr, ctx);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue