diff options
Diffstat (limited to 'src/main/kotlin/pl/treksoft/kvision/html/Button.kt')
-rw-r--r-- | src/main/kotlin/pl/treksoft/kvision/html/Button.kt | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/main/kotlin/pl/treksoft/kvision/html/Button.kt b/src/main/kotlin/pl/treksoft/kvision/html/Button.kt index ec0fd881..4e8f7b3e 100644 --- a/src/main/kotlin/pl/treksoft/kvision/html/Button.kt +++ b/src/main/kotlin/pl/treksoft/kvision/html/Button.kt @@ -1,6 +1,7 @@ package pl.treksoft.kvision.html import com.github.snabbdom.VNode +import org.w3c.dom.events.MouseEvent import pl.treksoft.kvision.core.ResString import pl.treksoft.kvision.core.Widget import pl.treksoft.kvision.snabbdom.StringBoolPair @@ -87,4 +88,12 @@ open class Button( return super.getSnAttrs() + ("type" to "button") } + open fun onClick(handler: Button.(MouseEvent) -> Unit): Button { + this.setEventListener<Button> { + click = { e -> + self.handler(e) + } + } + return this + } } |