"Enabled" property binding

I’ve got a situation where the user can add new product IDs to the database, and the first thing I do is check if the ID already exists (there are a bunch of other qualifiers, but that’s all you need for this example). If the ID exists, I force the number they entered back to zero.

The button’s “enabled” property is bound to the int in the numeric input box being greater than zero. But, it doesn’t work correctly when I programatically set the number back to zero. To get it to go back to disabled again, I have to open the bindings dialog and close it again, and then it refreshes.

I also tried programatically setting “enabled” to 0, but that didn’t work either. Obviously, the expression binding never sees an update from one value to another and back to zero. Is that how this is supposed to work? I know I could just drop the binding and control it all programatically, but the binding would be cleaner. Can I force a refresh of the binding?

I’ve attached a window so you can see what I mean. If you enter any number but “2”, the “test” button should be enabled. If you enter “0” or “2”, the button should go disabled.
Enabled.zip (4.46 KB)

I think your only problem is that you’re setting intValue from within the propertyChange of intValue itself. This is breaking the ‘rules’ as far as event propogation goes. So you think: “its changing to a 2, and then I change it back to a 0”, but what really happens is that “It starts changing to a 2, then I change it to a 0, and then the change to 2 completes”.

Throw the reset to zero in an invokeLater call, and you should be all set, like this:

if event.propertyName == 'intValue': if event.source.intValue ==2: def reset(event=event): event.source.intValue = 0 system.util.invokeLater(reset)