You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
Is it the good way (code below) if I want to chain on_change event on custom TextField.
importfletasftclassTextField(ft.TextField):
def__init__(self, *args, **kwargs):
# save instance on_changeself._on_change=kwargs.get('on_change')
super().__init__(*args, **kwargs)
# redefine class on_changeself.on_change=self.__cls_on_changedef__cls_on_change(self, e):
# here do what you have to do in class TextField# ...print("on_change from class", e.data)
# call instance on_change if definedifself._on_change:
self._on_change(e)
defmain(page: ft.Page) ->None:
page.window.width=500page.window.height=300page.window.center()
defon_change(e):
print("on_change from instance", e.data)
page.add(TextField(on_change=on_change))
ft.app(target=main)
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi,
Is it the good way (code below) if I want to chain on_change event on custom TextField.
Best regards
Beta Was this translation helpful? Give feedback.
All reactions