aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/pl/treksoft/kvision/html
diff options
context:
space:
mode:
authorRobert Jaros <rjaros@finn.pl>2018-04-03 17:23:23 +0200
committerRobert Jaros <rjaros@finn.pl>2018-04-03 17:23:23 +0200
commit65545f31a1f6e20857f4283ecec4790046971d6f (patch)
tree6c8be823864e42bc24ef9b03b5e6e2a17e8fff05 /src/main/kotlin/pl/treksoft/kvision/html
parent946d432023da1e2bb60c8d4c7260a6d486f7f53b (diff)
downloadkvision-65545f31a1f6e20857f4283ecec4790046971d6f.tar.gz
kvision-65545f31a1f6e20857f4283ecec4790046971d6f.tar.bz2
kvision-65545f31a1f6e20857f4283ecec4790046971d6f.zip
Add onClick event handler for Link component
Diffstat (limited to 'src/main/kotlin/pl/treksoft/kvision/html')
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/html/Link.kt13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/main/kotlin/pl/treksoft/kvision/html/Link.kt b/src/main/kotlin/pl/treksoft/kvision/html/Link.kt
index d1cf9a12..5fc613e2 100644
--- a/src/main/kotlin/pl/treksoft/kvision/html/Link.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/html/Link.kt
@@ -22,6 +22,7 @@
package pl.treksoft.kvision.html
import com.github.snabbdom.VNode
+import org.w3c.dom.events.MouseEvent
import pl.treksoft.kvision.core.Container
import pl.treksoft.kvision.core.ResString
import pl.treksoft.kvision.core.StringPair
@@ -72,6 +73,18 @@ open class Link(
return pr
}
+ /**
+ * A convenient helper for easy setting onClick event handler.
+ */
+ open fun onClick(handler: Link.(MouseEvent) -> Unit): Link {
+ this.setEventListener<Link> {
+ click = { e ->
+ self.handler(e)
+ }
+ }
+ return this
+ }
+
companion object {
/**
* DSL builder extension function.