Expose FocusReason to .slint as an argument in focus-event-changed and add focus-gained and focus-lost callbacks (#8569)

This exposes FocusReason to .slint, and adds it as an argument to focus-event-changed callback on FocusScope to close #8387. It also adds two new callbacks, focus-gained and focus-lost, which are identical to focus-event-changed but are only invoked on focus gain or loss respectively.

In addition to this, it removes the FocusEventReason::AccessKit variant, replacing it with the mouse variant to hopefully make AccessKit more compatible with any Slint code that will use FocusEventReason.

Finally, I added two tests based on focus_change_event.slint, one for testing the FocusEventReason argument and another for testing the new callbacks.

close #8387

ChangeLog: Added `focus-gained` and `focus-lost` callback to FocusScope.  Pass an `FocusReason` enum to the FocusScope callbacks
This commit is contained in:
Avery Townsend 2025-06-04 03:51:26 -04:00 committed by GitHub
parent d7ae61ec3a
commit 8c4ccabf7d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
22 changed files with 343 additions and 84 deletions

View file

@ -215,6 +215,7 @@ fn default_config() -> cbindgen::Config {
rename: [
("Callback".into(), "private_api::CallbackHelper".into()),
("VoidArg".into(), "void".into()),
("FocusReasonArg".into(), "FocusReason".into()),
("KeyEventArg".into(), "KeyEvent".into()),
("PointerEventArg".into(), "PointerEvent".into()),
("PointerScrollEventArg".into(), "PointerScrollEvent".into()),
@ -323,6 +324,7 @@ fn gen_corelib(
"InputType",
"StandardButtonKind",
"DialogButtonRole",
"FocusReason",
"PointerEventKind",
"PointerEventButton",
"PointerEvent",
@ -375,6 +377,7 @@ fn gen_corelib(
"CallbackOpaque",
"WindowAdapterRc",
"VoidArg",
"FocusReasonArg",
"KeyEventArg",
"PointerEventArg",
"PointerScrollEventArg",