Need to click several times to execute scripts I.E. buttons

Hi, i have several buttons on several different screens.
Often i have to click the same button between 1 and 5-6 times before the mouseClick even fires.

Even when there is such small script like this

[code]data = event.source.parent.parent.getComponent(‘Table’).data
pds = system.dataset.toPyDataSet(data)
selRow = event.source.parent.parent.getComponent(‘Table’).selectedRow

if selRow != -1:
nr = str(pds[selRow][0])
name = str(pds[selRow][1])

#event.source.parent.getComponent('txtName').text = txt
if system.gui.confirm("<HTML>&Auml;r du s&auml;ker p&aring; att du vill ta bort <B>" + name + "</B>?","Verkligen ta bort?"):
	system.db.runUpdateQuery("DELETE FROM RecipeData WHERE RecipeID=" + nr)
	system.db.runUpdateQuery("DELETE FROM Recipe WHERE RecipeID=" + nr)
	tableData = event.source.parent.parent.getComponent('tblNewEvent')
	i = 1[/code]

I still have to click often several times.

Is there any chance you have an infinite event loop somewhere else on that window? That would typically be a propertyChange event on one object that changes a property on another, which triggers its propertyChange event, which then changes the first property again. Or some other chain of events that keep triggering themselves. When the GUI event loop bogs down, some events will be lost. Sometimes, many events are lost.
To debug something like this, put a print statement in each event routine on the page that prints the event object. Then watch the diagnostics console to see what’s happening.
Another possibility is running long computations in an event routine – that’ll block other events from firing. A general rule of thumb is any user-invoked event routine should complete in 1/10th of a second or less. Other event routines should be even faster. Slow events should trigger their computation to run in the background with system.util.invokeAsynchronous()

[quote=“pturmel”]Is there any chance you have an infinite event loop somewhere else on that window? That would typically be a propertyChange event on one object that changes a property on another, which triggers its propertyChange event, which then changes the first property again. Or some other chain of events that keep triggering themselves. When the GUI event loop bogs down, some events will be lost. Sometimes, many events are lost.
To debug something like this, put a print statement in each event routine on the page that prints the event object. Then watch the diagnostics console to see what’s happening.
Another possibility is running long computations in an event routine – that’ll block other events from firing. A general rule of thumb is any user-invoked event routine should complete in 1/10th of a second or less. Other event routines should be even faster. Slow events should trigger their computation to run in the background with system.util.invokeAsynchronous()[/quote]

Hi.
Only in 2 popup pages i had propertyChange used, now added to check if event.propertyName == “data”, and only run then.

But still on full pages where i only have 2 buttons (except the navigation template i created), there is no scripts on that page, and yet, i have often click 4-5 times before the buttons navigation happens.

[attachment=0]screenshot.png[/attachment]

Use actionPerformed in a button, not mouseClicked.
After setting the navigation you want, click on the script editor tab and add the print event statement to the top of the script. Report what you see in the console for each click. If you see print output with no navigation action, wait. Your problem might just be a problem opening the next window. Add print event statements to every script in the window you are trying to open, including inside any templates.
{ On propertyChange events, the print event statement should be inside each “if event.propertyName==” block. Never do anything in any propertyChange event without checking the propertyName. That’s a quick way to an infinite loop. }

[quote=“pturmel”]Use actionPerformed in a button, not mouseClicked.
After setting the navigation you want, click on the script editor tab and add the print event statement to the top of the script. Report what you see in the console for each click. If you see print output with no navigation action, wait. Your problem might just be a problem opening the next window. Add print event statements to every script in the window you are trying to open, including inside any templates.
{ On propertyChange events, the print event statement should be inside each “if event.propertyName==” block. Never do anything in any propertyChange event without checking the propertyName. That’s a quick way to an infinite loop. }[/quote]

Hi, what is the difference between mouseClicked and actionPerformed?
In most other languages i know, mouseClicked is usually the function to use, when one wants something to happens when the user clicks on the button/object.

[quote=“StefanGronberg”][quote=“pturmel”]Use actionPerformed in a button, not mouseClicked.
After setting the navigation you want, click on the script editor tab and add the print event statement to the top of the script. Report what you see in the console for each click. If you see print output with no navigation action, wait. Your problem might just be a problem opening the next window. Add print event statements to every script in the window you are trying to open, including inside any templates.
{ On propertyChange events, the print event statement should be inside each “if event.propertyName==” block. Never do anything in any propertyChange event without checking the propertyName. That’s a quick way to an infinite loop. }[/quote]

Hi, what is the difference between mouseClicked and actionPerformed?
In most other languages i know, mouseClicked is usually the function to use, when one wants something to happens when the user clicks on the button/object.[/quote]

mouseClicked only fires when the user presses the mouse button and releases it without moving the cursor at all. Quite often when a user presses the mouse button there is some very small movement of the cursor before they release the button. People do this without even realizing it.

You can see how much conscious effort it takes to do a click without moving the cursor by adding a button with a print statement in the mouseClicked event and watch the console for the output.

For components without an actionPerformed event I use the mouseReleased event to avoid this issue.

The primary purpose of actionPerformed is to unify the behavior of a button when it is clicked to activate or if it was activated by space/enter after tabbing or otherwise using the keyboard to focus it.

Thanks all.

I moved all mouseClicked to actionPerformed, and everything seems more responsive now.

This has helped me out a lot. Thanks for the tips. My question for the Ignition guys is why is mousedClicked not more robust? Why would actionPerfomed be any different than mouseClicked if you were clicking the mouse? I understand the difference between the two as far as clicks, tabs, and enters but I don’t see why the action of clicking would be any different between the two.

Mouse clicking is purely that. And the event handler must account for different buttons and OS differences in event ordering. ActionPerformed is the generic that is expected to work for a simple (left) click or keyboard activation. It is also the event that you can expect to work when dealing with blind/disabled users.