Created
March 7, 2010 07:29
-
-
Save bluepapa32/324232 to your computer and use it in GitHub Desktop.
Undoable Drag and Drop in JavaFX
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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