Event listeners

Hi @pmclornan, welcome to the forum!

The easiest way to run some code following user input is to use the event handlers. This great article explains it very well.

https://anvil.works/learn/tutorials/feedback-form/chapter-4/10-set-up-an-event-handler

If it is a text box used for data input, the standard event handlers are
image

When this event occurs, the associated function will run

  def text_box_1_pressed_enter(self, **event_args):
    """This method is called when the user presses Enter in this text box"""
...
    # Write your function in here to carry out the nex steps

  def text_box_1_lost_focus(self, **event_args):
    """This method is called when the TextBox loses focus"""
    # this could be an alternative event handler

You can make the same function run on either event just by changing the handler call.

Does this answer your question?

4 Likes