|
Replies:
5
-
Last Post:
Aug 8, 2008 6:41 AM
by: stanhirsh
|
Threads:
[
Previous
|
Next
]
|
|
|
|
|
|
Drag 'n Drop
Posted:
Aug 1, 2008 2:48 AM
|
|
|
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
|
|
|
|
|
|
|
Re: Drag 'n Drop
Posted:
Aug 1, 2008 2:58 AM
in response to: stanhirsh
|
|
|
Below is a simple example:
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
}
|
|
|
|
|
|
|
|
Re: Drag 'n Drop
Posted:
Aug 1, 2008 8:28 AM
in response to: alexsch
|
|
|
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
|
|
|
|
|
|
|
|
Re: Drag 'n Drop
Posted:
Aug 2, 2008 6:26 AM
in response to: stanhirsh
|
|
|
When you are dragging something and release the mouse, the dragged object gets the endDrag-Event, not 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.
|
|
|
|
|