From 99dcb8e434d7e0ccf5dada379c1b03e894e6aa82 Mon Sep 17 00:00:00 2001 From: Robert Jaros Date: Wed, 26 Feb 2020 13:30:23 +0100 Subject: Major changes in the event handling architecture. Support for multiple event handlers. --- .../main/kotlin/pl/treksoft/kvision/form/spinner/Spinner.kt | 13 ++++++++----- .../kotlin/pl/treksoft/kvision/form/spinner/SpinnerInput.kt | 3 ++- 2 files changed, 10 insertions(+), 6 deletions(-) (limited to 'kvision-modules/kvision-bootstrap-spinner/src/main/kotlin/pl') diff --git a/kvision-modules/kvision-bootstrap-spinner/src/main/kotlin/pl/treksoft/kvision/form/spinner/Spinner.kt b/kvision-modules/kvision-bootstrap-spinner/src/main/kotlin/pl/treksoft/kvision/form/spinner/Spinner.kt index 69d9410b..c8b51372 100644 --- a/kvision-modules/kvision-bootstrap-spinner/src/main/kotlin/pl/treksoft/kvision/form/spinner/Spinner.kt +++ b/kvision-modules/kvision-bootstrap-spinner/src/main/kotlin/pl/treksoft/kvision/form/spinner/Spinner.kt @@ -201,18 +201,21 @@ open class Spinner( } @Suppress("UNCHECKED_CAST") - override fun setEventListener(block: SnOn.() -> Unit): Widget { - input.setEventListener(block) - return this + override fun setEventListener(block: SnOn.() -> Unit): Int { + return input.setEventListener(block) } @Deprecated( "Use onEvent extension function instead.", ReplaceWith("onEvent(block)", "pl.treksoft.kvision.core.onEvent") ) - override fun setEventListener(block: SnOn.() -> Unit): Widget { + override fun setEventListener(block: SnOn.() -> Unit): Int { @Suppress("DEPRECATION") - input.setEventListener(block) + return input.setEventListener(block) + } + + override fun removeEventListener(id: Int): Widget { + input.removeEventListener(id) return this } diff --git a/kvision-modules/kvision-bootstrap-spinner/src/main/kotlin/pl/treksoft/kvision/form/spinner/SpinnerInput.kt b/kvision-modules/kvision-bootstrap-spinner/src/main/kotlin/pl/treksoft/kvision/form/spinner/SpinnerInput.kt index 3a52fed2..f195234a 100644 --- a/kvision-modules/kvision-bootstrap-spinner/src/main/kotlin/pl/treksoft/kvision/form/spinner/SpinnerInput.kt +++ b/kvision-modules/kvision-bootstrap-spinner/src/main/kotlin/pl/treksoft/kvision/form/spinner/SpinnerInput.kt @@ -27,6 +27,7 @@ import pl.treksoft.kvision.core.Container import pl.treksoft.kvision.core.StringBoolPair import pl.treksoft.kvision.core.StringPair import pl.treksoft.kvision.core.Widget +import pl.treksoft.kvision.core.onEvent import pl.treksoft.kvision.form.FormInput import pl.treksoft.kvision.form.InputSize import pl.treksoft.kvision.form.ValidationStatus @@ -151,7 +152,7 @@ open class SpinnerInput( ButtonsType.HORIZONTAL -> this.addSurroundingCssClass("kv-spinner-btn-horizontal") } this.surroundingSpan = true - this.setInternalEventListener { + this.onEvent { change = { self.changeValue() } -- cgit