Event Listeners

the event listeners handle the events from UI components by defining the behavior after the event is triggered. We have several pre-defined event and the handlers as follows

Events

Button.click

        "confirm_start_btn.click": {
            'goto': "choose_topic_state",
            "preload_page": "learn_page",
            "switch_page": True,
        },
        "language.change": {
            'goto': "setup_state",
            'update': 'topic'
        },

Audio.stop_recording

        "input_word_audio.stop_recording": {
            'goto': "practice_word_pronunciation_state",
            "update": "word_pronounce_score",
        },

Gallery.select

Handlers

goto

jump to another state

update

update the value of some UIType

switch_page

define whether the event will possibly change the page

preload_page

define whether we need to preload the next page (update the value of UIType on the next page)

play

play the audio given by the audio_info

enable/disable

make some UIType enabled/disabled

select_index

save the selected index of a Gallery to the ctx with the given variable name.

clear

clear the output of several UITypes

ctx_handler

perform some action given the value in the ctx. For example, the above code means when choice_0_button clicked, it will check the value of quiz_status and display some information.

Last updated