MouseClicked event on template instance not working

I have a template with only Text Field component in it. I want a script to run when I click on this template’s instance. I have put a script on MouseClicked event of this template’s instance. There is no script on any event of the template or the Text Field.

Reading through other posts, I understood that Java Swing triggers ‘innermost’ script only. But with no script in template, I thought the script on template instance should run.

Am I missing something?

What script is on your MouseClicked? Lets make sure there’s nothing wrong there first.

Script contains function to open a popup system.nav.openWindow(windowPath). I also tried with simple print statement but got the same result.

When you’re clicking the template, are you clicking inside the text box, or just the general area?

I’m pretty sure the text field component has a built-in listener for mouse clicks, in order to gain focus. So it would never pass clicks to a parent.

1 Like

I am clicking inside the text box. Size of text field and template is kept same.

Yes, text field component has a mouse clicked event. If I write the same script on text field (inside template), then it gets triggered when I click on the instance.
So, does it mean that what I am trying to do (having script on mouse clicked event of instance instead of inside template) is not possible?

Yes, likely not possible.

Instead, consider writing what you need in a custom method on the instance, and have the label delegate to that. Something like this:

event.source.parent.parent.parent.someCustomMethod(event)

{ Adjust number of .parent references for your situation. }