JavaFX ListView with touch events for scrolling up and down -



JavaFX ListView with touch events for scrolling up and down -

i implement scrollable listview gestures, in mobiles , tablets, scroll , downwards list finger. current list selects item click downwards on list. how can accomplish this? couldn't find illustration @ oracle tutorials.

private observablelist<document> items = fxcollections.observablearraylist(); @fxml listview<document> listview; { ... listview.setitems(items); listview.getstylesheets().add("style/listview.css"); listview.setstyle("-fx-background-insets: 0 ;"); // remove 1px border of listview container listview.setcellfactory(new callback<listview<document>, listcell<document>>() { @override public listcell<document> call(listview<document> listview) { homecoming new documentarrayadapter(); } }); ... } public void loadlistview(list<document> ldoc){ if (!ldoc.isempty()){ items.addall(ldoc); } }

this i've made

public class customlistcell extends listcell<document>{ private double lastyposition = 0; public customlistcell(){ setonmousepressed(new eventhandler<mouseevent>() { @override public void handle(mouseevent event) { lastyposition = event.getsceney(); } }); setonmousedragged(new eventhandler<mouseevent>() { @override public void handle(mouseevent event) { double newyposition = event.getsceney(); double diff = newyposition - lastyposition; lastyposition = newyposition; customscrollevent cse = new customscrollevent(); cse.fireverticalscroll((int)diff, documentarrayadapter.this, (eventtarget) event.getsource()); } });

and

package myproject.utils; import javafx.event.event; import javafx.event.eventtarget; import javafx.scene.input.scrollevent; public class customscrollevent { public void fireverticalscroll(int deltay, object source, eventtarget target){ scrollevent newscrollevent = null; newscrollevent = new scrollevent(source, target, scrollevent.scroll, 0, 0, 0, 0, false, false, false, false, false, false, 0, deltay, 0, 0, scrollevent.horizontaltextscrollunits.characters, 0, scrollevent.verticaltextscrollunits.none, deltay, 0, null); event.fireevent(target, newscrollevent); } }

although i've implemented listener in own listcell, guess work implementing listeners straight @ listview, listview.setonmousepressed , listview.setonmousedragged

listview javafx gestures

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -