propertyChange does not work for me

I have a customProperty called counter that increments every second

I want that when it reaches 10sec, it closes the page... what am I doing wrong?

if event.propertyName == 'counter':  
        if event.newValue == 10:  
            system.nav.closeWindow('2-DEVELOP/2-SYSTEM/3-BMS LEVELS/Popup Maitenance Mode/ProgressBar_Counter')

Please edit your post to use "Preformatted text" formatting for the code you pasted. It's the button in the comment editor that looks like this: </>
We can't see your indentation, and it matters.


On what @pturmel 's point it seems like you have 8 spaces indented on your line on your first indented if statement but it should be 4 spaces or 1 tab. Try fixing your indentation first and then see if you're still experiencing an issue (and open up console and see if it's spitting out an errors).

The first step when something doesn't work is to open the console and see if there are errors there.
Maybe nothing happens because something is broken. The console will tell you that.

yes I have corrected it and it is still the same, in fact I put a print "house" in the following line and it does not print it by console

I just tried this and it works as expected:

if event.propertyName == 'counter' and event.newValue == 10:
	print "Hey there"

Did you create the customPropertie inside the root.container of the window where we are making the script?

The event must be on the root container, not the window, if you are monitoring a root container property. Putting the event on the window will only catch changes to the window's own properties.

1 Like

I don't understand, if I want a window to close when a counter (customProperty) is equal to 5 (that's what I want to do). I have the custom created inside the root container of the PopupWindow and it is that custom that I am trying to interact with the closing of the window.

A property change event is only sent to the component that has the property. The root container of a window is not the window. Move your event script to the root container.


omg!!! now I see it... indeed that was... thank you very much for the class Phill! I learned a lot with that explanation.