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

Callback when window loses or gains focus #4460

Open
PlanetTeamSpeakk opened this issue Jan 27, 2024 · 1 comment
Open

Callback when window loses or gains focus #4460

PlanetTeamSpeakk opened this issue Jan 27, 2024 · 1 comment
Labels
a:builtin elements The runtime data structures related to the items (mO,bT) api Changes or additions to APIs enhancement New feature or request

Comments

@PlanetTeamSpeakk
Copy link

I have made a small app that is in its entirety partially transparent (achieved by putting all elements in the window in a Rectangle and making the Rectangle slightly transparent). I use a FocusPane on the entire window to update the opacity of this rectangle whenever the window loses focus (making it only slightly visible), however, I also have a LineEdit element on this window and when the focus moves there, the window loses focus even though the focus is still inside of the window.

The way I currently circumvent this, is by waiting a few microseconds after the window loses focus and then checking if the LineEdit has gotten focus. This wait is necessary as it seems that the LineEdit hasn't yet gotten focus by the time the callback is called for the Window's FocusPane.

In my application, there's only one element that can take away focus, so it's not that tedious to check for this, however, I still feel like it's a little unnecessary, especially since Winit (and I can only assume other backends too) fire an event when the window gains or loses focus.

Hence, I'd like to request this event fired by the backend be propagated into a callback in Window, fired when the focus is moved into or out of the window.

As a little side-note, it'd also be nice if every element that has a has-focus property would also get a callback for when its focus changes. LineEdit, for example, doesn't have such a callback.

@hunger hunger added the enhancement New feature or request label Jan 28, 2024
@hunger
Copy link
Member

hunger commented Jan 30, 2024

We are working on being able to register callbacks to trigger when a property changes, which solves the has-focus problem nicely :-) That's tracked in #112

This does nto effect the Window-level callbacks you are asking for.

@hunger hunger added a:backend-winit Winit backend (mS,mO) api Changes or additions to APIs a:builtin elements The runtime data structures related to the items (mO,bT) and removed a:backend-winit Winit backend (mS,mO) labels Jan 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:builtin elements The runtime data structures related to the items (mO,bT) api Changes or additions to APIs enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants