Hi,
I am trying the following:
self.content_panel.raise_event_on_children(event_name="TimerTick")
with the hope that a form that I loaded as a child of a column panel can pick that event up.
However, I get the following error:
`ExternalError: TypeError: Cannot read properties of undefined (reading 'match')`
* `at Main, line 42`
Fwiw, the code in the child form is:
def TimerTick(self, **event_args):
self.updateFeed()
I’m basically trying to expose children forms to the timer event on the “Main” / entry form
Where is line 42?
And what is in line 42?
And what is “match”?
2 Likes
Ditto on what Stefano asked.
In addition, function names and event names are not the same. Event names are what you see in the properties panel for a component, all the way at the bottom. The event name for the timer is not TimerTick.
1 Like
Sorry - I should have specified.
MainForm:
def timer_1_tick(self, **event_args):
"""This method is called Every [interval] seconds. Does not trigger if [interval] is 0."""
self.content_panel.raise_event_on_children(event_name="TimerTick") #`Line 42:`
No clue what “match” is, nothing I have is named match. I was trying to get it to call this function in a child-form object.
ChildForm:
def TimerTick(self, **event_args):
self.updateFeed()
To illustrate:
MainForm (contains 5second timer that user can turn on or off).
MainForm → Child Forms [Form1, Form2] in a column container dynamically.
Form1 → Contains some def TimerTick() that does something specific to that instance of Form1 (call it print(‘hi world’))
Form 2 → Contains the def TimerTick() you see above.
One other approach, I just dont know how to do it, that would work is if there is a way for child forms to inherit the Tick event from a timer on a parent form
Again, the event name doesn’t correspond to a function name. If you want to use raise_event_on_children
and specify your own custom event, you will need to, on the children, setup an event handler to call your TimerTick function when the event is triggered.
You can see the basic structure for this in this post: Custom events best practices
Note that you must name your custom events starting with x-
Got it, thanks. I’m still getting that “match” error though:
ExternalError: TypeError: Cannot read properties of undefined (reading 'match')
(Parent) MainForm:
def timer_1_tick(self, **event_args):
"""This method is called Every [interval] seconds. Does not trigger if [interval] is 0."""
self.content_panel.raise_event_on_children(event_name="x-Timer-Tick") # line 42 in the error
(Child) Form2:
def __init__(self, **properties):
# Set Form properties and Data Bindings.
self.init_components(**properties)
# Set Form Event Handlers
self.set_event_handler("x-Timer-Tick", self.TimerTick)
def TimerTick(self, **event_args):
self.updateFeed()
def updateFeed(self, **args):
print('hi world')
Figured it out.
You have to remove the "event_name="
portion of raise_event_on_children
1 Like