What's the best way to discover which TableColumn (in a TableView) that a DragEvent occurred?
I'd like to be able to highlight (ex. change the background color to yellow, or show a yellow border around the column) a TableColumn as a dragged item is "hovering" over the it, to make it clear to the user which column they're dropping onto. After the drag is finished of course I'll have to make sure the TableView's style is restored.
To be clear, the exact cell being dropped onto doesn't matter - just the column.
To do this, you need to register drag listeners with each cell that cause the column to update its style when the cells are dragged over. I would do this using an
ObjectProperty
to represent the current "drop target column" (i.e. column over which dragging is occurring), and both observe it and update it from the cells. To access the cells, you need a cell factory.The following method will add such support to a column. It also respects any functionality defined in a previously-attached cell factory:
Here's a SSCCE using the usual "contact table" example:
and the stylesheet: