I had this interesting issue come out of QA this morning and other than creating rowfactory for each table - I wanted to see if there was a more straightforward way to accomplish the following.
User double clicks on a record in the table - it launches some behavior. But only do this if they click on an actual row, not the header, or empty space in the table under the rows.
We have this type of code through out our system:
myTable.setOnMouseClicked(event -> {
if (event.getClickCount() == 2) {
MyDTO dto = myTable.getSelectionModel().getSelectedItem();
if(dto != null) {
//Do my processing
}
}
});
What our QA tester did was select a row, then double click empty space or the header in the table. This doesn't deselect the record, so the processing fires.
Is there a way to determine at this point if the click happened on a row, or so I need to move my code to a row factory?