Trigger onActionPerformed from another component

I want to trigger the onActionPerformed event on a button when onKeyUp == 'Enter' on a Text Field component. Is this possible? I was thinking message handler, but I don't know what the function would be to trigger the action. self.onActionPerformed()?

I don't know that you can call onActionPerformed directly, but you can right click on a component -> Configure Scripts and add a method:

Then, you'll be able to call that method from anywhere on that view.

So, what you can do is move your onActionPerformed logic to one or more component methods, then on the Button that has the method, you would just call it using

self.printMessage('hello')    # replace with your method

That way, your logic is in one place if you need to modify it and you have the ability to execute code within a view. If you need to communicate within a view, I would stay away from view-scoped message handlers and use only component methods.

2 Likes

perfect, this is what I was looking for, thanks!