cssfx icon indicating copy to clipboard operation
cssfx copied to clipboard

CSSFX doesn't monitor changes in Application stylesheet

Open Liso-cz opened this issue 4 years ago • 7 comments

When I define global CSS file for all stages of javafx application (see below), then changes aren't reloaded.

        final URL globalCssFile = getClass().getResource("styles/Global.css");
        Application.setUserAgentStylesheet(globalCssFile.toExternalForm());

Liso-cz avatar Jan 26 '21 23:01 Liso-cz

@McFoggy Any news on this issue?

palexdev avatar Mar 03 '21 17:03 palexdev

Any news on this issue?

Not really. I had a quick look at it but the global stylesheet is not Observable and is a bit special thus it will require a special handling and probably either a specific monitoring or a new API to be called by CSSFX users.

McFoggy avatar Mar 04 '21 08:03 McFoggy

Also, new JavaFX versions (9+) seems to have introduced a regression. In JavaFX 8 I was able to change the user agent stylesheet and then call reapplyCss() or impl_reapplyCss() and the new style would be applied It doesn't work anymore though

palexdev avatar Mar 04 '21 10:03 palexdev

@palexdev please do not mix problems in the same issue, open another issue describe the problem and potentially provide a reproducer. By the way as we do not touch the user agent style, is it related to CSSFX? did you try to reproduce without it?

McFoggy avatar Mar 04 '21 14:03 McFoggy

Sorry I thought it might be a useful information. No, it's not related to CSSFX, it's related to this change JDK-8088253, reverting that commit fixes the problem, I'm testing it further and then I'm going to contact the devs

palexdev avatar Mar 04 '21 15:03 palexdev

It looks like a bit tricky issue or inappropriate use case. Do you know any workaround? I'd like to use CssFx, but I also want to have one global CSS file, which I don't need to include in every new window opened by application. The code above was the only solution I'd found out. It's not the best one, because then I need to have modena.css included in my global.css file via @include. Does JavaFX provide any other solution? Anyway, Thanks for your time!

Liso-cz avatar Mar 05 '21 18:03 Liso-cz

The only workaround I see right now is to include your CSS in the top windows instead. If you find some other ways, fill free to send a PR.

McFoggy avatar Mar 06 '21 08:03 McFoggy