aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/pl/treksoft/kvision/form/check
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/form/check
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/form/check')
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/form/check/CheckBox.kt10
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/form/check/CheckInput.kt10
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/form/check/Radio.kt10
3 files changed, 30 insertions, 0 deletions
diff --git a/src/main/kotlin/pl/treksoft/kvision/form/check/CheckBox.kt b/src/main/kotlin/pl/treksoft/kvision/form/check/CheckBox.kt
index 4faee7e7..6776b8eb 100644
--- a/src/main/kotlin/pl/treksoft/kvision/form/check/CheckBox.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/form/check/CheckBox.kt
@@ -1,5 +1,6 @@
package pl.treksoft.kvision.form.check
+import org.w3c.dom.events.MouseEvent
import pl.treksoft.kvision.core.Widget
import pl.treksoft.kvision.form.BoolFormControl
import pl.treksoft.kvision.form.FieldLabel
@@ -126,4 +127,13 @@ open class CheckBox(
}
return cl
}
+
+ open fun onClick(handler: CheckBox.(MouseEvent) -> Unit): CheckBox {
+ this.setEventListener<CheckBox> {
+ click = { e ->
+ self.handler(e)
+ }
+ }
+ return this
+ }
}
diff --git a/src/main/kotlin/pl/treksoft/kvision/form/check/CheckInput.kt b/src/main/kotlin/pl/treksoft/kvision/form/check/CheckInput.kt
index a3ccd126..7114b2c2 100644
--- a/src/main/kotlin/pl/treksoft/kvision/form/check/CheckInput.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/form/check/CheckInput.kt
@@ -1,6 +1,7 @@
package pl.treksoft.kvision.form.check
import com.github.snabbdom.VNode
+import org.w3c.dom.events.MouseEvent
import pl.treksoft.kvision.core.Widget
import pl.treksoft.kvision.form.INPUTSIZE
import pl.treksoft.kvision.snabbdom.StringBoolPair
@@ -110,4 +111,13 @@ open class CheckInput(
getElementJQuery()?.prop("checked", this.value)
}
}
+
+ open fun onClick(handler: CheckInput.(MouseEvent) -> Unit): CheckInput {
+ this.setEventListener<CheckInput> {
+ click = { e ->
+ self.handler(e)
+ }
+ }
+ return this
+ }
}
diff --git a/src/main/kotlin/pl/treksoft/kvision/form/check/Radio.kt b/src/main/kotlin/pl/treksoft/kvision/form/check/Radio.kt
index 4dc0ac90..d7fa502f 100644
--- a/src/main/kotlin/pl/treksoft/kvision/form/check/Radio.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/form/check/Radio.kt
@@ -1,5 +1,6 @@
package pl.treksoft.kvision.form.check
+import org.w3c.dom.events.MouseEvent
import pl.treksoft.kvision.core.Widget
import pl.treksoft.kvision.form.BoolFormControl
import pl.treksoft.kvision.form.FieldLabel
@@ -141,4 +142,13 @@ open class Radio(
}
return cl
}
+
+ open fun onClick(handler: Radio.(MouseEvent) -> Unit): Radio {
+ this.setEventListener<Radio> {
+ click = { e ->
+ self.handler(e)
+ }
+ }
+ return this
+ }
}