Skip to content

Instantly share code, notes, and snippets.

@ahinchman1
Created February 28, 2018 04:55
Show Gist options
  • Save ahinchman1/86b406dd140650bd34ef891ef0bdacb8 to your computer and use it in GitHub Desktop.
Save ahinchman1/86b406dd140650bd34ef891ef0bdacb8 to your computer and use it in GitHub Desktop.
/**
* Compare selected dragging tile with the location of the drop
* and render the module tile accordingly
*
* @property MouseEvent evt
*/
private fun drop(evt : MouseEvent) {
val mousePt = workArea.sceneToLocal( evt.sceneX, evt.sceneY )
val targetNode = evt.target as Node
val tileTarget = targetNode.findParentOfType(Tile::class)
// if "Return to Workbench" is clicked, buttonTarget is assigned
val buttonTarget = targetNode.findParentOfType(Button::class)
if (::inFlightTileProperties.isInitialized && isDragAndDrop) {
if (tileTarget is Tile && workArea.contains(mousePt) &&
inFlightTileProperties.title.toIntOrNull() == null) {
pickGridTile(mousePt.x, mousePt.y)
root.children[1].getChildList()!!.remove(inFlightTile)
inFlightTileProperties.width = 100.0
inFlightTileProperties.height = 100.0
isDragAndDrop = false
}
}
if (buttonTarget is Button && buttonTarget.textProperty().value == "Return to Workbench") {
workbenchController.returnToWorkbench(this@TileGUI)
}
evt.consume()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment