halirutan
11/22/2019, 11:07 AMdiv("App-header") {
attrs.onDragOverFunction = { event -> event.preventDefault() }
attrs.onDropFunction = ::filesDropped
but the onDropFunction
has the signature Event -> Unit
. I'm trying to follow some html5 JS tutorial and to access the files that were dropped, they use ev.dataTransfer
, but in Kotlin this is only available for DragEvent
. The problem is that the provided event
is not of type DragEvent
and something like this fails
private fun filesDropped(event: Event) {
console.log("Files dropped")
event.preventDefault()
val dragEvent = event as DragEvent
val items = dragEvent.dataTransfer?.items ?: return
Is there a simple example/tutorial how to do this in Kotlin?halirutan
11/22/2019, 5:02 PMval dragEvent = event.unsafeCast<DragEvent>()