aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/pl/treksoft/kvision/html
diff options
context:
space:
mode:
authorRobert Jaros <rjaros@finn.pl>2018-01-29 20:55:50 +0100
committerRobert Jaros <rjaros@finn.pl>2018-01-29 20:55:50 +0100
commit6cf546ffb334155b41af49cc7e2b25873204627d (patch)
treedf3c1324c836829be06b2e96612e56c442a6f837 /src/main/kotlin/pl/treksoft/kvision/html
parent9a70dcb74707dac6d7e88d9b75ddf36b17fd5632 (diff)
downloadkvision-6cf546ffb334155b41af49cc7e2b25873204627d.tar.gz
kvision-6cf546ffb334155b41af49cc7e2b25873204627d.tar.bz2
kvision-6cf546ffb334155b41af49cc7e2b25873204627d.zip
Dedicated onClick event handler on buttons
Diffstat (limited to 'src/main/kotlin/pl/treksoft/kvision/html')
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/html/Button.kt9
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
+ }
}