https://kotlinlang.org logo
#compose-desktop
Title
# compose-desktop
z

Zoff

12/11/2023, 10:20 AM
how can i detect if my main window has focus or not? can't seem to manage that
a

Alexander Maryanovsky

12/11/2023, 10:37 AM
Copy code
LocalWindowInfo.current.isWindowFocused
z

Zoff

12/11/2023, 11:02 AM
ah thanks. is there also a callback when focus changes?
a

Alexander Maryanovsky

12/11/2023, 11:02 AM
You can convert any Compose state to a flow with
snapshotFlow
or just use
Copy code
LaunchedEffect(windowInfo.isWindowFocused) {
    if (windowInfo.isWindowFocused) {
        ...
    }
}
👍 1
2 Views