On Thu, 18 Jul 2024 15:26:59 GMT, Andy Goryachev <ango...@openjdk.org> wrote:
> Thank you for the detailed writeup! I did not know about > `Region.getUserAgentStylesheet()`, especially about its doc "Some JavaFX CSS > implementations may choose to cache this response for an indefinite period of > time, and therefore there should be no expectation around when this method is > called." How are we supposed to implement dynamically changing styles?? The `Region` based system doesn't look well thought out, but I suppose you can force a reload of all styles by changing something at a higher level (like `Scene`). I didn't know it existed either, and it seems to behave differently to other user agent stylesheets (with Application / Scene / SubScene, only one applies, while `Region` can complement it further...) -- I'm guessing this is intended for 3rd parties, so they can style their controls without those styles competing at the same level as author stylesheets (ie. they're sort of "extending" modena). As for dynamically changing styles, it depends on who wants those. If it is the control developer, they can ensure their stylesheet has multiple variants and use a top level selector for changing between one or the other (for example between light and dark). If it is the user of the control, they can do so normally by just replacing stylesheets (or preferably, also using a selector, as that's much faster). > Do I understand you correctly that `Scene.setUserAgentStylesheet()` > completely replaces modena.css for that Scene? And then > Scene.getStylesheets() will lay on top of that, having higher priority? Yes, that's correct. The code will not use the platform user agent stylesheet when there is either a scene or subscene user agent stylesheet available. This seems to make it possible to say have a Scene in modena style, and another Scene in caspian style without the Application stylesheet potentially interfering. And yes, Scene.getStylesheets layers on top of all that (but those are author stylesheets, so they overrule the user agent stylesheets anyway). ------------- PR Comment: https://git.openjdk.org/jfx/pull/1503#issuecomment-2237377760