Skip to content

Add support for the Back key on Android #9172

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dfaure
Copy link
Contributor

@dfaure dfaure commented Aug 16, 2025

Successfully tested with this code

forward-focus: my-key-handler;
my-key-handler := FocusScope {
    key-pressed(event) => {
        if (event.text == Key.Back) {
            root.close();
        }
        accept
    }
}

but also without (that was the hard part: letting Android terminate the activity on Back if it's not accepted by slint, which no longer happened after returning Some(...) in key_codes.rs)

@dfaure dfaure force-pushed the wip/dfaure/android_back_key branch 2 times, most recently from 2b212c6 to fcc484b Compare August 16, 2025 00:55
@dfaure dfaure force-pushed the wip/dfaure/android_back_key branch 2 times, most recently from cb2a161 to 9b644ef Compare August 16, 2025 11:24
Successfully tested with this code

    forward-focus: my-key-handler;
    my-key-handler := FocusScope {
        key-pressed(event) => {
            if (event.text == Key.Back) {
                root.close();
            }
            accept
        }
    }

but also without (that was the hard part: letting Android
terminate the activity on Back if it's not accepted by slint,
which no longer happened after returning Some(...) in key_codes.rs)
@dfaure dfaure force-pushed the wip/dfaure/android_back_key branch from 9b644ef to f26459f Compare August 16, 2025 12:20
Copy link
Member

@ogoffart ogoffart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, looks good to me.

@dfaure
Copy link
Contributor Author

dfaure commented Aug 16, 2025

widgets_combobox_qt seems to fail reliably in CI after these changes, surprisingly.

However I don't manage to run that test locally:

 SLINT_TEST_FILTER=combo cargo test -p test-driver-rust --features build-time

   Compiling test-driver-rust v1.13.0 (/d/slint/tests/driver/rust)
error[E0433]: failed to resolve: could not find `NativeComboBox` in `sp`
 --> /d/slint/target/debug/build/test-driver-rust-510c5e5728f3f3d2/out/widgets_combobox_qt.rs:1:22529
  |
1 | ...* & InnerComboBox_root_4 :: FIELD_OFFSETS . r#native_6 } + sp :: r#NativeComboBox :: FIELD_OFFSETS . r#current_value) . apply_pin (_self) , ({ InnerComboBox_root_4 :: FIELD_OFFSETS . r#b...
  |                                                                     ^^^^^^^^^^^^^^^^ could not find `NativeComboBox` in `sp`

(and more similar errors)
i-slint-backend-qt builds just fine.

@ogoffart
Copy link
Member

could not find NativeComboBox in sp

I have seen that before. I think it's a bug in the build script which somehow think Qt feature is active despite it is not (maybe because confused with other build)
Can add --features=slint/backend-qt to the cargo line

@tronical
Copy link
Member

It’s weird how another PR I made earlier today passed nicely, but this one somehow triggers the QComboBox test (not build) failure.

There are warnings about threading that are also worrisome (not caused by this patch).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants