Dropdown propertyChange not fired on Enabled property

As the title says, I don’t seem to get an event fired when the Enabled property on my Dropdown component is changed. The Enabled property is bound to something.

I am trying to set the selectedStringValue to -1 so that it will display the “No Selection Label” when the component is disabled.

This is my code on the propertyChange event script:

if event.propertyName == "componentEnabled":
	if event.newValue == 0:
		event.source.selectedStringValue = "-1"
		event.source.parent.getComponent('Label 7').text = "Disabled"
	else:
		event.source.parent.getComponent('Label 7').text = "Enabled"
	# end if
	
# end if

The label text change is just for debugging, the label text isnt changing regardless of what the newValue is so it seems to me the event just isnt firing. Why might this be?

Are propertyChange event scripts fired before the bindings are or something?
Or can the scripts not work when a component is enabled… In which case i’d still expect it to change my label when the component is Enabled again.

It looks like the property description needs to be updated. The property name should be enabled, but the scripting name on the property says componentEnabled.

If you’re curious how I figured it out, I simply added print event.propertyName above your example.

I’ll make a ticket to update the description, but in the meantime you should be able to get your code to work by changing the property name your line 1 is filtering on.

if event.propertyName == "enabled":
1 Like

Ah yep thats working. Ironically i did start to write “enabled” but then checked the tooltip and changed it before testing the code…

Thanks!

In the interest of posterity, componentEnabled is the correct scripting name of the ‘Enabled’ property that is found in the Property Editor. The problem here is that the componentEnabled property just doesn’t fire changes that propertyChange can catch (which is true of many properties).

The enabled property mentioned above is a separate property that does fire a change, which is why the code above started working. The enabled property is what actually disables the component, but considers both the value of componentEnabled as well as any component security settings that are attempting to disable the component.

A brief overview of the two properties:
componentEnabled = the value of “Enabled” property in the Property Editor.
enabled = componentEnabled’s value AND component security settings

1 Like