Kilua guide
  • Kilua Guide
  • Introduction
  • Compose world
  • 1. Getting Started
    • Setting Up
    • Creating a New Application
    • Modules
    • Development Workflow
    • Hot Module Replacement
    • Debugging
    • Building For Production
  • 2. Frontend Development Guide
    • Composable functions
    • Browser APIs
    • Interoperability with JavaScript
    • Working with Compose
    • Rendering HTML
    • Type-safe CSS properties
    • Resources
    • Icons
    • Routing
    • Layout containers
    • Events
    • Forms
    • SVG images
    • Drag and drop
    • Internationalization
    • REST client
    • Markdown and sanitization
    • Using Bootstrap
    • Using TailwindCSS
    • Using Tabulator
    • Animation
    • Using Jetpack Compose API
  • 3. Fullstack Components
  • Useful References
Powered by GitBook
On this page
  1. 2. Frontend Development Guide

Drag and drop

All Kilua components have built-in support for HTML5 drag and drop. Any component can be draggable and any other component can play a role of a drop target. To make a component draggable just call setDragDropData method. You can set data format (it can be "text/plain" or other mime-type) and the data itself.

div {
    border(1.px, BorderStyle.Solid, Color.Black)
    width(100.px)
    height(100.px)
    setDragDropData("text/plain", "Element")
}

To create a drop target call setDropTargetData method. Use the format parameter to allow dropping only selected types of draggables. You can access the data transferred from the source element in the callback function.

div {
    width(200.px)
    height(200.px)
    setDropTargetData("text/plain") { data ->
        println("Dropped data: $data")
    }
}
PreviousSVG imagesNextInternationalization

Last updated 2 days ago