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

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

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

import com.soywiz.korev.*
import com.soywiz.korio.util.*
import com.soywiz.korui.native.*

open class UiToggleButton(app: UiApplication, val button: NativeUiFactory.NativeToggleButton = app.factory.createToggleButton()) : UiComponent(app, button) {
    var icon by button::icon
    var text by button::text
    var pressed by button::pressed
}

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




© 2015 - 2025 Weber Informatics LLC | Privacy Policy