edvin / tornadofx

Lightweight JavaFX Framework for Kotlin
Apache License 2.0
3.67k stars 270 forks source link

Default owner for openModal? #246

Closed dominiks closed 7 years ago

dominiks commented 7 years ago

On my dual screen setup openModal always opens on the primary screen when no owner is explicitly set - even when the application is used on the other screen. So I find myself always adding owner = FX.primaryStage to the call.

Is there a use case for having no owner in the modal? I'd think it would be a good way of reducing boilerplate to add the primaryStage as the default value for the owner parameter and also have the expected behaviour for a modal dialog.

edvin commented 7 years ago

Hi! Which version of TornadoFX are you running against? We made some changes to this behavior in 1.6.0 and 1.6.1. Can you verify that the issue is still there with 1.6.1. If so, I'll investigate and have it fixed :)

dominiks commented 7 years ago

Yes, also happens in 1.6.1.

edvin commented 7 years ago

I've added a property called currentWindow to UIComponent, which should point to either the modal window of the primary stage if no modal window is opened. This property is now the default value for the owner parameter for the openModal and openWindow functions.

I don't have a dual monitor setup here right now, so I'm unable to test it at the moment. Can you verify if this works as expected for you?

dominiks commented 7 years ago

Modals open on the correct screen in 1.6.2-SNAPSHOT when no owner is explicitly set. :+1:

edvin commented 7 years ago

Sweet! Thanks for this, it was a small but nice improvement :)