Skip to content

Add API to give an App focus #3032

Open
@freakboy3742

Description

@freakboy3742

What is the problem or limitation you are having?

When an app is currently active, it's possible to change which widget accepts input (i.e., has focus). However, it isn't possible to programmatically give an app focus if it isn't currently active.

Describe the solution you'd like

A new method App.focus() that ensures (to the extent possible) that the app is the currently active app.

Describe alternatives you've considered

Don't add the API. It's impolite for apps to change focus.

Additional context

This will be a no-op on mobile and console platforms; it will likely be ignored on GTK.

On macOS, it can be implemented with: App._impl.native.activateIgnoringOtherApps(True)

It will also be near impossible to verify in the testbed, because we can't programmatically give a different app focus. We can call the method... but only on the app that already, by definition, has focus.

Any documentation should highlight that it's really bad form for an app to bring itself into focus, so the method should be used sparingly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew features, or improvements to existing features.good first issueIs this your first time contributing? This could be a good place to start!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions