-
Notifications
You must be signed in to change notification settings - Fork 12
Description
I am looking for a way to react on the tray menu being opened that works consistently on Linux, macOS, and Windows.
My use case is a multi-platform application that is used to configure and monitor a remote service. The state of of the remote service is displayed in the application's main window as well as in an item entry of the tray menu. I poll for the state of the remote service while the main window of the application is open, but pause the polling as soon as it gets closed.
What I'd like to do now is to query the state of the remote service once every time the tray menu opens so I can update the displayed state.
The primary action does not fit this requirement on all platforms. On Linux it is converted into a tray item that needs to receive an additional left-click. (And the primary action, in my case, is to open the main window if it is closed.)
I tried to work around it by making the tray icon clickable via its modifier. But neither onClick nor clickable modifications worked for me.
Tray(
iconContent = {
Icon(
modifier = Modifier.fillMaxSize()
// neither of these options works (on linux, at least); intention was to update the client service status when the tray icon is clicked
// .onClick(onClick = { logger.info { "updating client service status because tray icon was clicked" } })
// .clickable(onClick = { logger.info { "updating client service status because tray icon was clicked" } })
)
},
// ...
)Is there another way to react to the tray menu being opened so its contents can be updated on demand?