Skip to content

[Android] Propagate the KeyEvents from Modal pages to MainActivity #30087

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: main
Choose a base branch
from

Conversation

Starchm
Copy link

@Starchm Starchm commented Jun 20, 2025

Note

Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!

Description of Change

Calls the MainActivity overrides from the ComponentDialog's overrides, so the previous behavior of KeyEvent handling of Modal pages is restored.

Issues Fixed

Fixes #30048

@Starchm Starchm requested a review from a team as a code owner June 20, 2025 10:15
@Starchm Starchm requested review from rmarinho and Aguilex June 20, 2025 10:15
@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Jun 20, 2025
Copy link
Contributor

Hey there @@Starchm! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

return activity.OnKeyLongPress(keyCode, e);
}

public override bool OnKeyDown([GeneratedEnum] Keycode keyCode, KeyEvent e)
Copy link
Member

Choose a reason for hiding this comment

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

I worry about firing through to the activity methods because that is going to possibly trigger other side effects

Here's the source code on onKeyUp from android

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (performMenuItemShortcut(event)) {
            return true;
        }
        return super.onKeyDown(keyCode, event);
    }

I'm not too sure the best path to take here

It seems like the keylistener and keyevent doesn't really express enough to be useful

Long term I think we could pipe these through platform lifecycle events but I know that doesn't super help right now in net9

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

Successfully merging this pull request may close these issues.

[Android] Modal pages does not trigger MainActivity KeyEvent overrides anymore
2 participants