Skip to content
This repository has been archived by the owner on Sep 28, 2024. It is now read-only.

Alert window is under main, when main is always on top #483

Closed
picoworm opened this issue Oct 5, 2017 · 1 comment
Closed

Alert window is under main, when main is always on top #483

picoworm opened this issue Oct 5, 2017 · 1 comment

Comments

@picoworm
Copy link
Contributor

picoworm commented Oct 5, 2017

Hi guys!

Recently I had problem similar to next:
https://stackoverflow.com/questions/41461064/javafx-how-do-i-set-an-alert-to-be-always-on-top

So I've copied alert function code from tornado fx and made it like this:

fun Node.alert(type: Alert.AlertType,
               header: String,
               content: String? = null,
               vararg buttons: ButtonType,
               actionFn: (Alert.(ButtonType) -> Unit)? = null): Alert {

    val alert = Alert(type, content ?: "", *buttons)
    alert.headerText = header
    alert.initOwner(scene.window) /* after this alert appears on top */
    val buttonClicked = alert.showAndWait()
    buttonClicked.ifPresent { actionFn?.invoke(alert, buttonClicked.get()) }
    return alert
}

Can this issue be fixed inside TornadoFX alert?

@edvin
Copy link
Owner

edvin commented Oct 5, 2017

Thanks for the tip, I've added owner as an optional parameter to the alert builder :)

@edvin edvin closed this as completed Oct 5, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants