Bindings and constraints question
Bindings and constraints question
- Subject: Bindings and constraints question
- From: "Mac Developer" <email@hidden>
- Date: Tue, 28 Aug 2007 10:44:37 -0700
I have a model with objects (shapes) that have a few attributes (positionX,
and snapToGrid). The model also has the constraint that if snapToGrid=1 then
positionX has to be a multiple of 10.
Next I have an array controller with "contentArray" bound to the model's
shapes array.
Next I have an NSTextField with "value" bound to "selection.positionX".
To begin, there are 3 shapes with the attributes:
Shape 1: positionX=15, snapToGrid=0
Shape 2: positionX=30, snapToGrid=1
Shape 3: positionX=42, snapToGrid=0
The array controller has all of its objects (shapes) selected.
The text field displays its value for NSMultipleValuesMarker since there are
multiple values for positionX.
If I now type "25" in the text field, each of the shapes received a
"setPositionX" message. For shapes 1 and 3, the value is set to 25. However,
shape 2 cannot set its value to 25. Instead it sets it to 20 since the
snapToGrid parameter=1.
Now the shapes have the following attributes:
Shape 1: positionX=25, snapToGrid=0
Shape 2: positionX=20, snapToGrid=1
Shape 3: positionX=25, snapToGrid=0
However, the NSTextField still displays "25".
So the question is: How can I set things up so that the NSTextField displays
the correct value (NSMultipleValuesMarker ) after the user enters a value
that gets constrained by some, but not all, of the shapes?
Should I use the validate<key>:error: methods? If so, I need to make each
shape validate after the user has entered a value in the text field. How do
I do this?
Or should I use some other completely different technique?
(Example project is available upon request).
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden