Why do components trigger propertyChange script twice on one Enable property toggle?

I am using ignition 7.9.10 with a fresh drag-in-drop dropdown menu component instance.

Why does the component enable property trigger twice when state changes once? Currently triggering the state by toggling enable in the ignition designer properties window. This component does not have any bindings or for bi-directional.

Property Change Script

print "property: " + event.propertyName
print "old: " + str(event.oldValue)
print "new: " + str(event.newValue)

customProperties = event.source.getProperties()
for x in range(len(customProperties)):
	print "custom property " + str(x) + ": " + str(customProperties[x])

OUTPUT

property: enabled
old: True
new: False
custom property 0: Test1
custom property 1: test2
custom property 2: test3
property: enabled
old: True
new: False
custom property 0: Test1
custom property 1: test2
custom property 2: test3

No idea. But I hope you know to use an if block that checks the propertyName for any script that actually does anything. Failure to do so can be catastrophic.

If you really need to see only one event, you will to need to program in a debounce.

This example uses a custom property called enableDebounce:

if event.propertyName == 'enabled':
  if event.newValue == True and event.source.enableDebounce == 0:
    event.source.enableDebounce = 1
    print 'Enabled'
  if event.newValue == False and event.source.enableDebounce == 1:
    event.source.enableDebounce = 0
    print 'Disabled'

You should see what repainting looks like. There can be dozens of calls to repaint for a single action, that’s just the nature of GUI programming. Of course, repainting is idempotent; if you have side effects, you need to record whether or not you’ve already started or finished them.

1 Like

100% the script needs an IF statement; I removed to test all properties like visibility only fires once.

So far, I can only get a dropdown menu to double trigger on enabled. Buttons, Checkboxes, TabStrips do not double fire, and I’m 50% through testing all components on the palette. Fun Stuff.

print 'p: ' + str(event.propertyName) + ' old: ' + str(event.oldValue) + ' New: ' + str(event.newValue)