0

I've been trying to use listeners on gluon CharmListView for a while. It didn't work in my project so i decided to try it on the FIFTY STATES app. I added the code below:

charmListView.onMouseClickedProperty().set((MouseEvent event) ->{
                            Logger.getGlobal().log(Level.INFO, "Pick: {0}", new Object[]{event.getPickResult()});
                        });

When I launch the application, NO click fires aMOUSE_CLICKED event. When I scroll down slightly such that the a list header cell is fully docked like this,enter image description here

the CharmListView fires the event only on a click on the top header cell.

INFO: Pick: PickResult [node = VBox@49f31558[styleClass=text-box], point = Point3D [x = 133.0, y = 13.0, z = 0.0], distance = 1067.366530964699

No other click anywhere else on the list fires an event. I've tried adding the same listener to the normal ListView and a MouseEvent is always fired after a click on any area of the ListView. So now I'm stuck because I cannot set a listener to get a selected item.

theking
  • 87
  • 13

1 Answers1

0

The CharmListView control is mainly intended for mobile applications, where you use scroll and swipe gestures. But these gestures trigger mouse clicked or pressed events.

If the list cells contain some event handler to process the latter, the only way scroll works is by consuming them, otherwise whenever you scroll the list, the cell event handler will be processed as well, when you start scrolling.

That's the reason why setOnMouseClicked() doesn't trigger any event if you click on the listView.

For accessing the list view selection model, please refer to this question.

Community
  • 1
  • 1
José Pereda
  • 44,311
  • 7
  • 104
  • 132