aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/pl/treksoft/kvision/html
diff options
context:
space:
mode:
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.