I've got a problem where the :hover CSS option is not working properly. This is the CSS:
.body:hover {
-fx-background-color: #b8fffd;
}
.exitIcon:hover {
-fx-fill: gray;
}
The body hover works fine but .exitIcon does not. In case I misspelled the className I also tried to use the FontAwesomeIconView selector but it still didn't work.
Here is the FXML code:
<AnchorPane prefHeight="800.0" prefWidth="1000.0" styleClass="body" stylesheets="@styles/lightSignalsStyles.css" xmlns="http://javafx.com/javafx/20.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.main.captainscompass.controllers.LightSignalsController">
<HBox alignment="CENTER_LEFT" prefHeight="200.0" stylesheets="@styles/lightSignalsStyles.css" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<FontAwesomeIconView glyphName="ARROW_LEFT" size="50" styleClass="exitIcon">
<cursor>
<Cursor fx:constant="HAND" />
</cursor>
</FontAwesomeIconView>
</HBox>
<HBox alignment="CENTER" prefHeight="200.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<Label text="Light Signals Quiz" textAlignment="CENTER">
<font>
<Font size="30.0" />
</font>
</Label>
</HBox>
<HBox alig`nment="CENTER_RIGHT" layoutX="10.0" layoutY="10.0" prefHeight="200.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<ImageView fitHeight="150.0" fitWidth="200.0" pickOnBounds="true" preserveRatio="true">
<Image url="@assets/sailboaticon.png" />
</ImageView>
</HBox>
</AnchorPane>
So I definitely didn't misspell the class name nor the file name since .body is actually working. And if I remove ":hover" the style is applied as expected. I really don't have a clue what's going on here as for every single other usage of :hover it works.
NOTE: This is not my main scene. I changed it using this logic:
FXMLLoader loader = new FXMLLoader(App.class.getResource(LIGHT_SIGNALS_FXML));
stage = (Stage)((Node)event.getSource()).getScene().getWindow();
Scene scene = new Scene(loader.load(), 1000, 800);
And in this scene NO events work not even something like onKeyPressed. But I still don't know what caused it.