Add fix for centering for all OS

This commit is contained in:
Manfred Karrer 2016-02-11 13:17:38 +01:00
parent e5faad5d05
commit 12b7555c66

View file

@ -100,10 +100,8 @@ public class Popup {
} }
public void hide() { public void hide() {
if (Utilities.isLinux() && owner != null && positionListener != null) {
owner.getScene().getWindow().xProperty().removeListener(positionListener); owner.getScene().getWindow().xProperty().removeListener(positionListener);
owner.getScene().getWindow().yProperty().removeListener(positionListener); owner.getScene().getWindow().yProperty().removeListener(positionListener);
}
if (centerTime != null) if (centerTime != null)
centerTime.cancel(); centerTime.cancel();
@ -255,10 +253,10 @@ public class Popup {
MainView.blurLight(); MainView.blurLight();
if (Utilities.isLinux()) {
// On Linux the owner stage does not move the child stage as it does on Mac // On Linux the owner stage does not move the child stage as it does on Mac
// So we need to apply centerPopup. Further with fast movements the handler loses // So we need to apply centerPopup. Further with fast movements the handler loses
// the latest position, with a delay it fixes that. // the latest position, with a delay it fixes that.
// Also on Mac sometimes the popups are positioned outside of the main app, so keep it for all OS
positionListener = (observable, oldValue, newValue) -> { positionListener = (observable, oldValue, newValue) -> {
if (stage != null) { if (stage != null) {
centerPopup(); centerPopup();
@ -271,7 +269,6 @@ public class Popup {
owner.getScene().getWindow().xProperty().addListener(positionListener); owner.getScene().getWindow().xProperty().addListener(positionListener);
owner.getScene().getWindow().yProperty().addListener(positionListener); owner.getScene().getWindow().yProperty().addListener(positionListener);
} }
}
protected void centerPopup() { protected void centerPopup() {
Window window = owner.getScene().getWindow(); Window window = owner.getScene().getWindow();