Ignition template property change script

I have implemented a property change script for a template window to resize itself when its property value changes. This property value is tied to a tag value.
However, i notice sometimes this property change script is not invoked even though the binded tag value changes.

What could cause this property change script not to be invoked? Is there a way to workaround it?

Do you have any conditional statements in your property change script? It’s common for property change scripts to have conditionals like if currentValue == True or something along the lines of that. Maybe you’re preventing the property change script from executing?

Have, i am checking the custom property’s propertyName and value in the if condition. I have checked the conditions are met, but somehow the script is not being executed.

Any idea why?

We aren’t telepathic. (Well, I’m not.) Show your code. Provide details of your template and the tag binding.

You haven't made a module for this yet ?

1 Like

Hi,

Here’s my code. Appreciate some advice and suggestions here.

if event.propertyName == 'intTogglePopup':
	if event.source.intTogglePopup == 0:
		component = event.source	
		rootContainer = event.source.parent
		currentZOrder = rootContainer.getComponentZOrder(component)
		try:
			#Change the minus to a plus to move the Z Order/Index of the Object/Component to a higher 'layer'
			rootContainer.setComponentZOrder(component,0)
			component.requestFocusInWindow()
		except:
			pass	
	
		objComp = event.source
		origX = objComp.x
		origY = objComp.y
		intNewWidth = 0
		intNewHeight = 0
			
		system.gui.transform(
			objComp,
			origX,origY, intNewWidth, intNewHeight,
			duration=500,
			acceleration=system.gui.ACCL_FAST_TO_SLOW
		)		
	else:
		component = event.source	
		rootContainer = event.source.parent
		currentZOrder = rootContainer.getComponentZOrder(component)
		try:
			#Change the minus to a plus to move the Z Order/Index of the Object/Component to a higher 'layer'
			rootContainer.setComponentZOrder(component,0)
			component.requestFocusInWindow()
		except:
			pass
		objComp = event.source
		origX = objComp.x
		origY = objComp.y
		intNewWidth = 1920
		intNewHeight = 1080
			
		system.gui.transform(
			objComp,
			origX,origY, intNewWidth, intNewHeight,
			duration=500,
			acceleration=system.gui.ACCL_FAST_TO_SLOW
		)

I’m not sure I can help with debugging, but here’s a suggestion: Don’t duplicate things. Here, most of the code is common to both branches of the if/else. Reassemble everything and only leave in the if/else what NEEDS to be there:

if event.propertyName == 'intTogglePopup':
	component = event.source	
	rootContainer = event.source.parent
	currentZOrder = rootContainer.getComponentZOrder(component)
	try:
		#Change the minus to a plus to move the Z Order/Index of the Object/Component to a higher 'layer'
		rootContainer.setComponentZOrder(component, 0)
		component.requestFocusInWindow()
	except:
		pass

	objComp = event.source
	origX = objComp.x
	origY = objComp.y

	if event.source.intTogglePopup == 0:
		intNewWidth = 0
		intNewHeight = 0			
	else:
		intNewWidth = 1920
		intNewHeight = 1080
			
	system.gui.transform(
		objComp,
		origX, origY, intNewWidth, intNewHeight,
		duration=500,
		acceleration=system.gui.ACCL_FAST_TO_SLOW
	)

Makes things easier to read and follow.

if event.source.intTogglePopup can only be 0 and 1, I’d suggest one of two things:

  1. Make it a boolean
  2. Use that to compute your values instead of using if/else:
intNewWidth = 1920 * event.source.intTogglePopup
intNewHeight = 1080 * event.source.intTogglePopup

Then, I’m a bit confused about a few things:

  • you’re not using currentZOrder. Did you forget to use it somewhere ?
  • I fail to see how the code in the try/except does what the comment says. How does setComponentZOrder(component, 0) changes a minus to a plus ?

hi

event.source.intTogglePopup will be 0 when we want to close the popup. event.source.intTogglePopup can be more than 1 to differentiate the different popups that we have. hence we can’t make event.source.intTogglePopup as boolean.

the issue where the above script didn’t get triggered is happening intermittently not always.

Any idea why above script didn’t get triggered is happening intermittently?

Consider adding a single line print event (temporarily) above the first line. Open the debug console while you recreate the problem. Examine the console to confirm that an event for intTogglePopup is happening when expected, and if so, that it contains the expected values.

(Don’t leave the print statement in place–it will be very noisy.)