All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.com.soywiz.korui.UiButton.kt Maven / Gradle / Ivy

There is a newer version: 4.0.10
Show newest version
package com.soywiz.korui

import com.soywiz.korev.MouseEvent
import com.soywiz.korui.native.NativeUiFactory

open class UiButton(app: UiApplication, val button: NativeUiFactory.NativeButton = app.factory.createButton()) : UiComponent(app, button) {
    var icon by button::icon
    var text by button::text
}

inline fun UiContainer.button(text: String = "Button", noinline onClick: (UiButton.(MouseEvent) -> Unit)? = null, block: UiButton.() -> Unit = {}): UiButton =
    UiButton(app)
        .also { it.text = text }
        .also { it.parent = this }
        .also { button -> if (onClick != null) button.onClick { onClick(button, it) }  }
        .also(block)




© 2015 - 2025 Weber Informatics LLC | Privacy Policy