Skip to content
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

Add API to give an App focus #3032

Open
freakboy3742 opened this issue Dec 8, 2024 · 1 comment
Open

Add API to give an App focus #3032

freakboy3742 opened this issue Dec 8, 2024 · 1 comment
Labels
enhancement New features, or improvements to existing features. good first issue Is this your first time contributing? This could be a good place to start!

Comments

@freakboy3742
Copy link
Member

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.

@freakboy3742 freakboy3742 added enhancement New features, or improvements to existing features. good first issue Is this your first time contributing? This could be a good place to start! labels Dec 8, 2024
@mhsmith
Copy link
Member

mhsmith commented Dec 11, 2024

For further discussion of whether we should add this API, see #3034 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New features, or improvements to existing features. good first issue Is this your first time contributing? This could be a good place to start!
Projects
None yet
Development

No branches or pull requests

2 participants