msink / kotlin-libui

Kotlin/Native interop to libui: a portable GUI library
MIT License
648 stars 49 forks source link

Simplify widgets creation #3

Closed lucasvsme closed 6 years ago

lucasvsme commented 6 years ago

This PR adds a lambda to some widgets to avoid using the apply scope function to setup the instance created. It also has a default value so those who want to use apply anyway can do without problems.

Before

val button = Button(text = "Click").apply {
    action {
        println("Hello World")
    }
}

After

val button = Button(text = "Click") {
    action {
        println("Hello World")
    }
}