Skip to content

Commit

Permalink
Docs: Add file drag & drop screenshot (#1759)
Browse files Browse the repository at this point in the history
Add file drag & drop screenshot
  • Loading branch information
soywiz authored Jul 3, 2023
1 parent cfb6cfe commit 8429d4c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 8 additions & 2 deletions docs/korge/reference/input/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -319,19 +319,25 @@ To do so, you can handle events of the type `DropFileEvent`.
For simplicity, there is a method you can call from a view to register to DropFileEvent:

```kotlin
view.onDropFile {
val dropFileRect = solidRect(Size(width, height), Colors.RED)
.visible(false)
onDropFile {
when (it.type) {
DropFileEvent.Type.START -> dropFileRect.visible = true
DropFileEvent.Type.END -> dropFileRect.visible = false
DropFileEvent.Type.DROP -> {
launchImmediately {
it.files?.firstOrNull()?.let { loadFile(it) }
it.files?.firstOrNull()?.let {
image(it.readBitmap()).size(Size(width, height))
}
}
}
}
}
```

![](file_drag_and_drop.gif)

Or if you want to register events directly:

```kotlin
Expand Down

0 comments on commit 8429d4c

Please sign in to comment.