How to fire mouse click event on a JavaFX ListView? -
how fire single , double mouse click events on first (or other) item of javafx.scene.control.listview?
i want receive event this:
getlistview().setonmouseclicked(mouseevent -> { switch (mouseevent.getclickcount()) { case 1: break; case 2: break; } });
there seems misunderstanding. events not fired on items of listview, on listcells display items. listcells may constructed dynamically , reused, there may not event target corresponding particular item.
if hands on correct node, fire event using event.fireevent:
node target = ... mouseevent mouseevent = new mouseevent(mouseevent.mouse_clicked, ...); event.fireevent(target, mouseevent); you find listcells using lookupall:
set<node> listcells = listview.lookupall(".list-cell"); and use listcell.getitem , listcell.getindex determine correct one.
but since event listener added listview finding correct listcell may not necessary.
Comments
Post a Comment