Callback when window loses or gains focus #4460
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
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.The text was updated successfully, but these errors were encountered: