tornadofx-controlsfx icon indicating copy to clipboard operation
tornadofx-controlsfx copied to clipboard

Show notification when stage is not in focused

Open sith opened this issue 6 years ago • 5 comments

This is probably controlsfx question but ...

Is it possible to show notification when application is collapsed or unfocused?

sith avatar Jul 19 '19 15:07 sith

It's actually more of a general JavaFX question I believe :)

In a TornadoFX UIComponent you can access the currentStage property, which is a javafx.stage.Stage. It has a focusedProperty you can listen to events on, and since Stage extends javafx.stage.Window, it also has callbacks for onShowing and onHiding.

edvin avatar Jul 19 '19 17:07 edvin

there is a scheduled task that should show notification after some time. But if app is hidden notification doesn't pop up. I am not sure I understand how this can be fixed with what you said

sith avatar Jul 19 '19 19:07 sith

I misunderstood you. The title says "show notification when stage is not focused", so I thought you wanted to show a notification when the stage no longer has focus :)

You can call currentWindow?.requestFocus(), which should make the application blink in the task bar. When the user clicks the blinking application icon, your notification would appear.

edvin avatar Jul 19 '19 19:07 edvin

That's a solution :) but there is no way to show it without focus?

sith avatar Jul 19 '19 20:07 sith

I'm not sure. You can check/ask on StackOverflow with a general JavaFX question. If you find a solution, please let me know on this issue :)

edvin avatar Jul 19 '19 20:07 edvin