mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-08-25 04:57:03 +00:00
The cocoa behavior is:
Exclusive bindings are impossible in IB Possible in code (tested with segmented control and selectedIndex & selectedTag) but then you get unexpected behavior. A segment can be selected after a click and then changes to another segment. After this commit, extra exclusive bindings are just ignored and we warn about it.
This commit is contained in:
@@ -454,8 +454,7 @@ var CPBindingOperationAnd = 0,
|
||||
|
||||
if (![CPBinder isBindingAllowed:aBinding forObject:self])
|
||||
{
|
||||
[CPException raise:CPGenericException
|
||||
reason:@"Cannot bind " + aBinding + " because a binding with the same functionality is already in use."];
|
||||
CPLog.warn([self description] + " : cannot bind " + aBinding + " because another binding with the same functionality is already in use.");
|
||||
return;
|
||||
}
|
||||
//if (![[self exposedBindings] containsObject:aBinding])
|
||||
|
||||
@@ -342,7 +342,7 @@
|
||||
[self assert:@"brie" equals:[control2 objectValue] message:@"control2 objectValue is wrong"];
|
||||
}
|
||||
|
||||
- (void)testExclusiveBindingsThrowsException
|
||||
- (void)testExclusiveBindings
|
||||
{
|
||||
var segmented = [[CPSegmentedControl alloc] initWithFrame:CGRectMakeZero()];
|
||||
[segmented setSegmentCount:3];
|
||||
@@ -351,10 +351,13 @@
|
||||
|
||||
[segmented bind:CPSelectedIndexBinding toObject:model withKeyPath:@"cheese" options:nil];
|
||||
|
||||
[self assertThrows:function()
|
||||
{
|
||||
[segmented bind:CPSelectedTagBinding toObject:model withKeyPath:@"cheese" options:nil];
|
||||
}];
|
||||
// Try to bind another binding (mutually exclusive) to the same value.
|
||||
[segmented bind:CPSelectedTagBinding toObject:model withKeyPath:@"cheese" options:nil];
|
||||
|
||||
[self assertNotNull:[segmented infoForBinding:CPSelectedIndexBinding]];
|
||||
|
||||
// Check that the source is not binded with the CPSelectedTagBinding
|
||||
[self assertNull:[segmented infoForBinding:CPSelectedTagBinding]];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user