Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removing stylesheets from scene not possible while using CSSFX #44

Open
dlemmermann opened this issue Feb 12, 2022 · 2 comments
Open

Removing stylesheets from scene not possible while using CSSFX #44

dlemmermann opened this issue Feb 12, 2022 · 2 comments
Assignees

Comments

@dlemmermann
Copy link

While working on dark mode support I noticed that I could not disable the dark mode anymore. I enable dark mode by adding additional stylesheets to my application. Then when I disable the dark mode I do so by removing those added stylesheets. This has no effect when using CSSFX.

@dlemmermann
Copy link
Author

Here is an example:

import fr.brouillard.oss.cssfx.CSSFX;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.ToggleButton;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;

public class CssFxTest extends Application {

    @Override
    public void start(Stage primaryStage) throws Exception {

        ToggleButton button = new ToggleButton("Switch");
        Scene scene = new Scene(new StackPane(button));

        button.selectedProperty().addListener(it -> {
            if (button.isSelected()) {
                scene.getStylesheets().add(CssFxTest.class.getResource("test-dark.css").toExternalForm());
            } else {
                scene.getStylesheets().remove(CssFxTest.class.getResource("test-dark.css").toExternalForm());
            }
        });

        primaryStage.setScene(scene);
        primaryStage.setTitle("CssFX Test");
        primaryStage.setWidth(400);
        primaryStage.setHeight(400);
        primaryStage.centerOnScreen();
        primaryStage.show();

        CSSFX.start();
    }

    public static void main(String[] args) {
        launch(args);
    }
}

The CSS file just needs this:

.root {
    -fx-base: black;
}

@McFoggy
Copy link
Owner

McFoggy commented Feb 23, 2022

feature was never implemented until now, code is there but empty :-(

@McFoggy McFoggy self-assigned this Feb 23, 2022
@McFoggy McFoggy added enhancement and removed bug labels Feb 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants