Button conflict on actionPerformed script!

Dear all,

I'm working on a Vision project where I have in my template a confirmation button that has an actionPerformed script to do the following:

1- Navigate into a popup-window.

2- The popup-window checks the user identity by inserting a serial number and then closes.

3- When the popup-window closes, it trigger a hidden button with a changeProperty script which has the ".doclick(confirmationbutton)" command, to click the confirmation button autmoatically.

image

On the side of the template I have a button to change the language from German to English and vice versa.
For somehow when I press the language change button, the popup-window opens, same as if I clicked on the confirmation button, and my guess is because the language button is effecting the confirmation button and because it is scripted with actionPerformed.

I tried changing actionPerformed script to mouseClicked, but in this case when the popup-window closes the button will not automatically be pressed.

I hope I made the process flow clear enough. Could you help me with a solution to keep the automatic click for the confirmation button and stopping the popup-window from openning when I change the language?

Thanks in advance.

This is not your problem. Any scripted action your button is supposed to perform should be done from actionPerformed not from mouseClicked.

You need to look at how is your property change script is qualified. Which if event.propertyName == are you using to trigger your script? If you're not qualifying your property change script, then it will fire no matter what property changes, including text properties on language changes.

4 Likes

Consider moving any important script on any component you need to reuse externally into a custom method, and for your own sake, pretending that doClick doesn't exist.

4 Likes

Thanks for your reply.

I have in this case four components, the confirmation button, the language button and the hidden button that trigers the doclick() command.
Which component do you mean to set it with a custom method ?

... into a project library script ...

4 Likes

Thanks a lot for your time.

I tried to dive into the library scripts, but I had some difficulties with the event and component's properties.
Although my trick to fix this conflict was to move the confirmation button script from actionPerformed into mousClicked. In this way changing the language wouldn't affect the button. And then make the hidden button that used to have the doClick() command, do the rest of the process that the confirmation button used to do.

I'm glad you got it working, but I wish you could share a little more, so we can guide you better. A hidden button, doClick, with split actionPerformed/mouseClicked scripts do not sound like standard practices. In five years, future you or whoever ends up maintaining this will probably have some difficulty in following this design. What I'm most interested in is your propertyChange event script because I believe that is what is causing the errant popup occurrences.

In a custom method or a project library script, anything that is needed from the environment they are being called from must be passed into them. so if you need to use the event or the component that is calling them, you will set them up like this:

def myCustomLibraryScript(event, component):
	#do work using the event and component here

When you call the script, it will look something like this:

myLibraryFolder.myCustomLibraryScript(event, component)
#this passes the needed objects into the function that is being called

If you use a custom method, it is the exact same thing, only you specify your parameters here:
image

When you call it, you will only specify the parameters; self will be the component that the custom method lives on:

hiddenButton.myCustomMethod(event, component)
#this passes the needed objects into the function that is being called
3 Likes

You mean, future you would fire past you :rofl: this sounds like a massive anti pattern

1 Like

OOPS!

2 Likes

Come on guys, give me a break :stuck_out_tongue_winking_eye:. tbh, I'm the one who's maintaining what someone has done previously, and the other guy is fired already :rofl:

Some of the ways I've done things when I first started I'd fire myself for today :sweat_smile: like calling queryStatus ~10 times in a Vision project... So bad. I had no idea why the client was so laggy

Lol

I mean you are laughing now, but your quick workaround is not really a fix.
Tip make a note somwhere what and where you "patched this". Tell your boss you found a work around but will need more time to fix the real issue.
Then its on your boss to decide if they want you to spend time on it now or later.
Make sure to do this by mail, This way you also have proof of why this bad code still is there.

6 Likes