commonMain.com.soywiz.korui.UiTextField.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of korgw Show documentation
Show all versions of korgw Show documentation
Portable UI with accelerated graphics support for Kotlin
package com.soywiz.korui
import com.soywiz.korev.*
import com.soywiz.korio.lang.*
import com.soywiz.korio.util.*
import com.soywiz.korui.native.*
open class UiTextField(app: UiApplication, val textField: NativeUiFactory.NativeTextField = app.factory.createTextField()) : UiComponent(app, textField) {
var text by RedirectMutableField(textField::text)
fun select(range: IntRange? = 0 until Int.MAX_VALUE): Unit = textField.select(range)
fun focus(): Unit = textField.focus()
fun onKeyEvent(block: (KeyEvent) -> Unit): Disposable = textField.onKeyEvent(block)
}
inline fun UiContainer.textField(text: String = "Button", block: UiTextField.() -> Unit): UiTextField {
return UiTextField(app).also { it.text = text }.also { it.parent = this }.also(block)
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy