JFXPanel Dragboard setDragView
Jeff Martin
jeff at reportmill.com
Mon Apr 21 22:39:46 UTC 2014
So I'm correct that calling Node.startFullDrag() should result in the OnMouseDragOver method getting called? I wasn't sure I had that right - and I really need a OnMouseDragMoved notification anyway.
My Sample code is below. If you think it should result in a bunch of onMouseDragOver.Handler printlns, I'll file a bug.
jeff
public void start(Stage aStage)
{
// Create Button with DragDetected.Handler to startFullDrag/startDragAndDrop
final Button button = new Button("Hello World");
button.setOnDragDetected(new EventHandler() {
public void handle(Event anEvent) {
button.startFullDrag();
Dragboard db = button.startDragAndDrop(TransferMode.ANY);
ClipboardContent cc = new ClipboardContent(); cc.putString("Hello World");
db.setContent(cc); anEvent.consume();
}
});
// Listen to DragSource events
button.setOnMouseDragOver(new EventHandler<MouseDragEvent>() {
public void handle(MouseDragEvent e) { System.out.println(e); }
});
// Add button to pane and stage and show
Pane pane = new Pane(); pane.setPrefSize(400,400);
pane.getChildren().add(button); button.resizeRelocate(100,100,100,100);
aStage.setScene(new Scene(pane)); aStage.show();
}
On Apr 21, 2014, at 8:45 AM, Anthony Petrov <anthony.petrov at oracle.com> wrote:
> Hi Jeff,
>
> On 4/18/2014 6:43 PM, Jeff Martin wrote:
>> I'm trying to figure out how to implement a version of Dragboard.setDragView() that works with JFXPanel (which isn't currently supported). Years ago I did this in Swing by creating a window that followed the mouse around (at an offset, so it wouldn't take all the DragOver events).
>>
>> I created a Popup Window and added an ImageView, but I can't figure out how to get the equivalent of DragSource events. I thought I could just call source.startFullDrag() in my DragDetected method then I would get MouseDrag events on my source, but that isn't happening. Is this a bug or am I doing something wrong?
>
> Please file a new JIRA and provide a small test case that demonstrates the problem.
>
>> Also, when I get my Popup moving, I'd really like it to be exactly under the mouse but have the Popup be MouseTransparent (or forward events to the window underneath).
>
> You could use the TRANSPARENT style for your popup window and paint a transparent hole (alpha == 0) in its center (or wherever you need it), and keep the popup positioned so that the mouse pointer is located above the hole. Mouse events always pass through transparent pixels. This way mouse events will get delivered to a window below the popup window in the z-order, while the popup window itself can float above it following the mouse cursor.
>
> --
> best regards,
> Anthony
More information about the openjfx-dev
mailing list