cappuccino/cappuccino — Issue #1463: Bindings: the source receives back the changes sent to the destination
Author: cacaodev
Created: 2012-02-23 20:15:31+00:00
State: open

Steps:
Bind a view in IB or in code to a CP(Object|Array)Controller. The controller can be linked to a model object or can auto-generate objects.
Change the value in the interface or send a setObjectValue: in code.

Result:
The CPBinder* object applies the changes from the source to the destination with reverseSetValueFor: . Then the destination sends back the value to the source with setValueFor:. When the source is a control, it will tipically setObjectValue: with the same value that just changed.

This bug can be best seen when the source is a text field and the continuouslyUpdatesValue option is on. If you place the cursor inside the string and type anything, the cursor will move to the end (because of setObjectValue:).

Expected result:
The source should not set again its value.

Discussion:
It's easy to suspend/resume observation in reverseSetValueFor: and stop the propagation and fix this bug.
But, if for any reason (that i am not aware of) it's not what we want, in any case we should prevent the view that receives the commit message to actually change its value.

Here is a test app that caches setValueFor: and reverseSetValueFor: messages and shows how many times they where triggered. It also shows other infos about bindings and bindings options.
I wrote it to demonstrate this bug but you can use it for testing bindings in general. Any binded view (IB or code) will be represented when you run the app.

BindingsMonitor: https://github.com/cacaodev/cappuccino/tree/BindingsMonitor
Online demo: http://cacaodev.pagesperso-orange.fr/Tests/Manual/BindingsMonitor/