Skip to content

Instantly share code, notes, and snippets.

@bluepapa32
Created March 7, 2010 07:29
Show Gist options
  • Select an option

  • Save bluepapa32/324232 to your computer and use it in GitHub Desktop.

Select an option

Save bluepapa32/324232 to your computer and use it in GitHub Desktop.
Undoable Drag and Drop in JavaFX
Draggable {
node: node
var translateX: Number;
var translateY: Number;
onStart: function(e) {
translateX = node.translateX;
translateY = node.translateY;
}
onDone: function(e) {
undoables.add(Undoable {
undo: {
def _translateX = translateX;
def _translateY = translateY;
function(): Void {
node.translateX = _translateX;
node.translateY = _translateY;
}
}
redo: {
def _translateX = node.translateX;
def _translateY = node.translateY;
function(): Void {
node.translateX = _translateX;
node.translateY = _translateY;
}
}
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment