javafx - No events when drag target is removed from the scenegraph while dragging -


javafx scene has object of class inherited region. object has handler of mouse_dragged event. when handler called, object's child nodes removed , new child nodes added. problem when children removed object, doesn't receive events anymore, because target of mouse_dragged event removed child node. how solve it?

i cannot use setmousetransparent method, because elements inside object have mouse event handlers.

ok, perhaps got question:

a region has many children. if user left-clicks , dragges on these children, modified or removed. mouse-drag event 'locked' first child drag started, no other child receive further events if mouse dragged on of other children.

you might benefit fact, mousedrag event passed parent region after removing child. possible register onmousedragged handler on th eparent regon receiving event. handler able 'pick' childs below mouse further actions using event.getpickevent():

void mousedragpop(pane region) {     region.setonmousedragged(e -> {         node node = e.getpickresult().getintersectednode();         if (node instanceof circle) {             region.getchildren().remove(node);         }     });      (int = 1; < 10; i++) {         final int n = i;         circle circle = new circle(20);         circle.settranslatex(0);         circle.settranslatey(0);         circle.setfill(color.rgb(180,  200,  170));         circle.setlayoutx(system.nanotime()/1000 % 200);         circle.setlayouty(system.nanotime()/3000 % 100);         region.getchildren().add(circle);          circle.setonmousedragged(e -> {             region.getchildren().remove(circle);             e.consume();         });     } } 

now able click , 'pop' circle on mouse-drag way... enter image description here


Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -