So I added the below fx-css to a list-cell.
.list-cell:selected:filled:hover {
-fx-view-order: -1;
-fx-effect: dropshadow(gaussian, #67676D, 12, 0.05, 0.0, 2);
}
Note when a list-cell is :selected its background is grey.
Now it seems the node boundaries are extended to the end of the drop shadow over the surrounding cells. This behavior is unwanted as the cell with the shadow captures events that should really be handled by the below or above cell.
Is there a fix for this?
Note: the same fx-css can be applied to a table-view and this unwanted functionally does not occur.
public class ListViewTest {
@Test
public void testFx() throws InterruptedException {
new JFXPanel();
CountDownLatch latch = new CountDownLatch(1);
Platform.runLater(() -> {
ListView<String> lv = new ListView<>();
lv.setCellFactory(param -> new ListCell<>() {
{
setPrefHeight(38);
hoverProperty().addListener((observable, oldValue, newValue) -> {
if (newValue) {
setStyle("""
-fx-view-order: -1;
-fx-effect: dropshadow(gaussian, #67676D, 12, 0.05, 0.0, 2);
""");
} else {
setStyle(null);
}
});
}
@Override
protected void updateItem(String item, boolean empty) {
super.updateItem(item, empty);
if (empty || item == null) {
} else {
}
}
});
var items = FXCollections.observableArrayList("1", "2", "3");
lv.setItems(items);
Stage stage = new Stage();
Scene scene = new Scene(lv);
stage.setScene(scene);
stage.show();
});
latch.await();
}
}
