Skip to main content

Drag 'n Drop

5 replies [Last post]
stanhirsh
Offline
Joined: 2008-08-01
Points: 0

Hi all,

is there some D&D functionality in the SDK ? Is it possible to make an object draggable and to enable another object (e.g. a simple rectange) to to recieve drops and broadcast onDrop events ?

Thanks, Stan

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
alexsch
Offline
Joined: 2007-07-12
Points: 0

See JFXC-1263 Add Drag and Drop to javafx.gui http://openjfx.java.sun.com/jira/browse/JFXC-1263

stanhirsh
Offline
Joined: 2008-08-01
Points: 0

Hi,

thanks for the quick reply. So moving objects around works pretty fine :-), but how can I make another object realize, that something has been dropped on it ?

Thanks, Stan

sleep
Offline
Joined: 2008-05-26
Points: 0

When you are dragging something and release the mouse, the dragged object gets the endDrag-Event, [i]not[/i] the item you are currently over. However, you can work out your own dropping code because while you are dragging, mouseOver-events are still caused whenever you move over a node. So simply have objects watch whether something is being dragged over them and have the endDrag-event cause the drag processing.

stanhirsh
Offline
Joined: 2008-08-01
Points: 0

Hi and thanks for the idea with the workaround, but is there really no built in DnD support, that would also allow me to pull a node out of a canvas and let´s say drop it on a tree-view-list in another window ?

Thanks, Stan

Edit: Apparently there was meant to be some native support for DnD - not sure if it is still there. Check:
http://markmail.org/message/42sdqq7zwtthelbg#query:javafx%20%22drag%20an...

Message was edited by: stanhirsh

alexsch
Offline
Joined: 2007-07-12
Points: 0

Below is a simple example:

[code]
import javafx.input.*;
import javafx.application.*;

import javafx.scene.paint.*;
import javafx.scene.geometry.*;

import java.lang.System;

var x = 100.0;
var y = 30.0;

Frame {
title: "Circle"
width: 200
height: 100
stage: Stage{
content: Circle {
centerX: bind x
centerY: bind y
radius: 25
fill: Color.ORANGE
stroke: Color.GREEN

onMouseDragged: function(e:MouseEvent) {
x = e.getX();
y = e.getY();
}

}
}
visible: true
}
[/code]