Lost focus not triggered

We may need to change this out of this topic, but for some reason the lost focus of my texbox is not triggered. Im still working on the data grid tutorial. This is the textbox to control the page size.

 def tb_pagesize_pressed_enter(self, **event_args):
    """This method is called when the user presses Enter in this text box"""
    print("pagesize entered")

 
  def tb_pagesize_lost_focus(self, **event_args):
    """This method is called when the TextBox loses focus"""
    print("Lost Focus")

Is it possible that the flow panel interferes with the lost_focus event?

Yes, this is a sufficiently different question so it has been moved to its own topic to keep things organized.

Have you set the callback function in the IDE?

sc

1 Like

Thanks @alcampopiano

I did not! I kind of thougth they were binded automatically. Cause when I double clicked on the textbox, I got the source with te event “enter_pressed”, so I though I had to just add the “lost_focus” event and that it would be recognize. But I see, I have to set it in the interface. It is not enough to add it to the code.

Thanks! I keep going.

In the designer, if you double click on a component with a click event, the IDE will automagically set up a callback function for you and take you to the code. It will also add the auto-generated function name to the “events” field in the IDE.

You can also set these so-called “event handlers” purely in code:

b=Button()
b.set_event_handler('click', self.my_function_when_click_happens)

def my_function_when_click_happens(self, **event_args):
# this runs when the button is clicked
.
.
.

In general, you will have many functions in your code, so components need to know which functions to run following a given event. Therefore, you connect components to their event handlers as described above.

1 Like

Thanks!

I keep going.