mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-04 10:50:00 +00:00
Add a clear-focus()
function on all elements that have a focus()
function
This is the counter-part, which removes focus from the element if it's currently focused. The window - if focused - may still be focused towards the windowing system.
This commit is contained in:
parent
e10e97c944
commit
31767eb6ab
21 changed files with 268 additions and 23 deletions
|
@ -3100,11 +3100,20 @@ fn compile_builtin_function_call(
|
|||
if let [llr::Expression::PropertyReference(pr)] = arguments {
|
||||
let window = access_window_field(ctx);
|
||||
let focus_item = access_item_rc(pr, ctx);
|
||||
format!("{}.set_focus_item({});", window, focus_item)
|
||||
format!("{}.set_focus_item({}, true);", window, focus_item)
|
||||
} else {
|
||||
panic!("internal error: invalid args to SetFocusItem {:?}", arguments)
|
||||
}
|
||||
}
|
||||
BuiltinFunction::ClearFocusItem => {
|
||||
if let [llr::Expression::PropertyReference(pr)] = arguments {
|
||||
let window = access_window_field(ctx);
|
||||
let focus_item = access_item_rc(pr, ctx);
|
||||
format!("{}.set_focus_item({}, false);", window, focus_item)
|
||||
} else {
|
||||
panic!("internal error: invalid args to ClearFocusItem {:?}", arguments)
|
||||
}
|
||||
}
|
||||
/* std::from_chars is unfortunately not yet implemented in gcc
|
||||
BuiltinFunction::StringIsFloat => {
|
||||
"[](const auto &a){ double v; auto r = std::from_chars(std::begin(a), std::end(a), v); return r.ptr == std::end(a); }"
|
||||
|
|
|
@ -2396,12 +2396,23 @@ fn compile_builtin_function_call(
|
|||
let window_tokens = access_window_adapter_field(ctx);
|
||||
let focus_item = access_item_rc(pr, ctx);
|
||||
quote!(
|
||||
sp::WindowInner::from_pub(#window_tokens.window()).set_focus_item(#focus_item)
|
||||
sp::WindowInner::from_pub(#window_tokens.window()).set_focus_item(#focus_item, true)
|
||||
)
|
||||
} else {
|
||||
panic!("internal error: invalid args to SetFocusItem {:?}", arguments)
|
||||
}
|
||||
}
|
||||
BuiltinFunction::ClearFocusItem => {
|
||||
if let [Expression::PropertyReference(pr)] = arguments {
|
||||
let window_tokens = access_window_adapter_field(ctx);
|
||||
let focus_item = access_item_rc(pr, ctx);
|
||||
quote!(
|
||||
sp::WindowInner::from_pub(#window_tokens.window()).set_focus_item(#focus_item, false)
|
||||
)
|
||||
} else {
|
||||
panic!("internal error: invalid args to ClearFocusItem {:?}", arguments)
|
||||
}
|
||||
}
|
||||
BuiltinFunction::ShowPopupWindow => {
|
||||
if let [Expression::NumberLiteral(popup_index), x, y, close_on_click, Expression::PropertyReference(parent_ref)] =
|
||||
arguments
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue