kvision / pl.treksoft.kvision.core / Widget / setEventListener

setEventListener

open fun <T : Widget> setEventListener(block: SnOn<T>.() -> Unit): Widget

Sets an event listener for current widget, keeping the actual type of component.

Parameters

T - widget type

block - event handler

Return

current widget

Example:

    button.setEventListener<Button> {
        dblclick = {
            Alert.show("Button double clicked!")
            // self is of type Button here
        }
    }

open fun setEventListener(block: SnOn<Widget>.() -> Unit): Widget

Sets an event listener for current widget.

Parameters

block - event handler

Return

current widget

Example:

    button.setEventListener {
        dblclick = {
            Alert.show("Button double clicked!")
            // self is of type Widget here
        }
    }