javafx 8 - TreeView using Drag and Drop incorrect getGestureSource() -
i have simple tree view drag , drop enabled. but, on setondragover()
call, receive event gesture source. source got not cell starts dragging (via setondragdetected()
call), pane contains tree view. missing ?
my code shown below:
tree.setcellfactory( new callback<treeview<string>, treecell<string>>() { @override public treecell<string> call( final treeview<string> param) { treecell<string> treecell = new treecell<string>() { @override protected void updateitem( final string value, final boolean empty) { super.updateitem(value, empty); if (!empty && (value != null)) { settext(value); setgraphic(gettreeitem().getgraphic()); } else { settext(null); setgraphic(null); } } }; treecell.setondragdetected(event -> { dragboard dragboard = startdraganddrop(transfermode.move); clipboardcontent content = new clipboardcontent(); content.putstring(treecell.gettreeitem().getvalue()); dragboard.setcontent(content); event.consume(); }); treecell.setondragover(event -> { // here i've got pane instead of cell object source = event.getgesturesource(); if ((event.getgesturesource() != treecell) && event.getdragboard().hasstring()) { event.accepttransfermodes(transfermode.move); } event.consume(); }); return treecell; } });
the gesture source node on startdraganddrop(...)
called; calling on whatever node instance in (i guess have custom subclass of pane
, or something).
so need
treecell.setondragdetected(event -> { dragboard dragboard = treecell.startdraganddrop(transfermode.move); // ... });
Comments
Post a Comment