how can i detect if my main window has focus or no...
# compose-desktop
z
how can i detect if my main window has focus or not? can't seem to manage that
a
Copy code
LocalWindowInfo.current.isWindowFocused
z
ah thanks. is there also a callback when focus changes?
a
You can convert any Compose state to a flow with
snapshotFlow
or just use
Copy code
LaunchedEffect(windowInfo.isWindowFocused) {
    if (windowInfo.isWindowFocused) {
        ...
    }
}
👍 1