diff options
author | Robert Jaros <rjaros@finn.pl> | 2018-04-03 17:23:23 +0200 |
---|---|---|
committer | Robert Jaros <rjaros@finn.pl> | 2018-04-03 17:23:23 +0200 |
commit | 65545f31a1f6e20857f4283ecec4790046971d6f (patch) | |
tree | 6c8be823864e42bc24ef9b03b5e6e2a17e8fff05 /src/main | |
parent | 946d432023da1e2bb60c8d4c7260a6d486f7f53b (diff) | |
download | kvision-65545f31a1f6e20857f4283ecec4790046971d6f.tar.gz kvision-65545f31a1f6e20857f4283ecec4790046971d6f.tar.bz2 kvision-65545f31a1f6e20857f4283ecec4790046971d6f.zip |
Add onClick event handler for Link component
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/kotlin/pl/treksoft/kvision/html/Link.kt | 13 |
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. |