mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-12-05 04:05:34 +00:00
Merge branch 'master' of github.com:cappuccino/cappuccino into cappuccino
This commit is contained in:
commit
5893b33962
10 files changed
+78
-9
No files matched your search
@@ -140,6 +140,8 @@ CPCheckBoxImageOffset = 4.0;
|
||||
[_source setAllowsMixedState:NO];
|
||||
}
|
||||
}
|
||||
else
|
||||
newValue = [self transformValue:newValue withOptions:options];
|
||||
|
||||
[_source setState:newValue];
|
||||
}
|
||||
|
||||
@@ -678,8 +678,11 @@ CPTableColumnUserResizingMask = 1 << 1;
|
||||
bindingInfo = binding._info,
|
||||
destination = [bindingInfo objectForKey:CPObservedObjectKey],
|
||||
keyPath = [bindingInfo objectForKey:CPObservedKeyPathKey],
|
||||
options = [bindingInfo objectForKey:CPOptionsKey],
|
||||
dotIndex = keyPath.lastIndexOf(".");
|
||||
|
||||
newValue = [binding reverseTransformValue:newValue withOptions:options];
|
||||
|
||||
if (dotIndex === CPNotFound)
|
||||
[[destination valueForKeyPath:keyPath] replaceObjectAtIndex:aRow withObject:newValue];
|
||||
else
|
||||
@@ -696,11 +699,6 @@ CPTableColumnUserResizingMask = 1 << 1;
|
||||
}
|
||||
}
|
||||
|
||||
//- (void)objectValue
|
||||
//{
|
||||
// return nil;
|
||||
//}
|
||||
|
||||
@end
|
||||
|
||||
var CPTableColumnIdentifierKey = @"CPTableColumnIdentifierKey",
|
||||
|
||||
@@ -369,6 +369,9 @@ var CPViewFlags = { },
|
||||
/* @ignore */
|
||||
- (void)_insertSubview:(CPView)aSubview atIndex:(int)anIndex
|
||||
{
|
||||
if (aSubview === self)
|
||||
[CPException raise:CPInvalidArgumentException reason:"can't add a view as a subview of itself"];
|
||||
|
||||
// We will have to adjust the z-index of all views starting at this index.
|
||||
var count = _subviews.length;
|
||||
|
||||
|
||||
@@ -69,8 +69,24 @@
|
||||
[self[KVOProxyKey] _removeObserver:anObserver forKeyPath:aPath];
|
||||
}
|
||||
|
||||
/*!
|
||||
Whether -willChangeValueForKey/-didChangeValueForKey should automatically be invoked when the
|
||||
setter of the given key is used. The default is YES. If you override this method to return NO
|
||||
for some key, you will need to call -willChangeValueForKey/-didChangeValueForKey manually to
|
||||
be KVO compliant.
|
||||
|
||||
The default implementation of this method will check if the receiving class implements
|
||||
`+ (BOOL)automaticallyNotifiesObserversOf<aKey>` and return the response of that method if it
|
||||
exists.
|
||||
*/
|
||||
+ (BOOL)automaticallyNotifiesObserversForKey:(CPString)aKey
|
||||
{
|
||||
var capitalizedKey = aKey.charAt(0).toUpperCase() + aKey.substring(1),
|
||||
selector = "automaticallyNotifiesObserversOf" + capitalizedKey;
|
||||
|
||||
if ([[self class] respondsToSelector:selector])
|
||||
return objj_msgSend([self class], selector);
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
||||
@@ -74,4 +74,28 @@
|
||||
[self assert:CPOnState equals:[control objectValue] message:"content 1 is on"];
|
||||
}
|
||||
|
||||
- (void)testTransformValueBinding
|
||||
{
|
||||
var control = [[CPCheckBox alloc] initWithFrame:CGRectMakeZero()];
|
||||
|
||||
content = [
|
||||
[CPDictionary dictionaryWithObject:YES forKey:@"state"],
|
||||
[CPDictionary dictionaryWithObject:NO forKey:@"state"]
|
||||
];
|
||||
arrayController = [[CPArrayController alloc] initWithContent:content];
|
||||
|
||||
// First test defaults.
|
||||
[control bind:CPValueBinding toObject:arrayController withKeyPath:@"selection.state" options:[CPDictionary dictionaryWithObject:@"CPNegateBoolean" forKey:CPValueTransformerNameBindingOption]];
|
||||
|
||||
[arrayController setSelectionIndexes:[CPIndexSet indexSetWithIndex:0]];
|
||||
[self assert:CPOffState equals:[control objectValue] message:"content[0] is negated"]
|
||||
[arrayController setSelectionIndexes:[CPIndexSet indexSetWithIndex:1]];
|
||||
[self assert:CPOnState equals:[control objectValue] message:"content[1] is negated"]
|
||||
|
||||
[control performClick:nil];
|
||||
[self assert:CPOffState equals:[control objectValue] message:"value was changed"]
|
||||
[self assert:YES equals:[content[1] valueForKey:@"state"] message:"content[1] was negated after change"]
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -178,7 +178,7 @@
|
||||
withKeyPath:@"weight"
|
||||
options:nil];
|
||||
|
||||
[self assert:20 equals:[button selectedTag]];
|
||||
[self assert:20 equals:[[button selectedItem] tag]];
|
||||
|
||||
[button selectItemAtIndex:1];
|
||||
// simulate selection by the user (this fails because we don't reverse set the value)
|
||||
|
||||
@@ -193,11 +193,37 @@
|
||||
notSame:class_getInstanceMethod([object class], removeSelector)];
|
||||
}
|
||||
|
||||
- (void)testAutomaticallyNotifiesObserversOf
|
||||
{
|
||||
var test = [ObservingTester new];
|
||||
|
||||
[test addObserver:self forKeyPath:@"cheese" options:0 context:nil];
|
||||
[test addObserver:self forKeyPath:@"astronaut" options:0 context:nil];
|
||||
|
||||
// Cheese shouldn't have been affected.
|
||||
[test setCheese:@"changed cheese"];
|
||||
[self assert:@"cheese" equals:_lastKeyPath]
|
||||
[self assert:test equals:_lastObject];
|
||||
|
||||
// Cheese shouldn't have been affected.
|
||||
[test setAstronaut:@"Armstrong"];
|
||||
// Nothing should have been observed because we don't automatically notify
|
||||
// and we didn't call will/didChange.
|
||||
[self assert:@"cheese" equals:_lastKeyPath message:"no observation when automatically notifies is off"];
|
||||
[self assert:test equals:_lastObject];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation ObservingTester : CPObject
|
||||
{
|
||||
id cheese;
|
||||
id astronaut @accessors;
|
||||
}
|
||||
|
||||
+ (BOOL)automaticallyNotifiesObserversOfAstronaut
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
+ (id)testerWithCheese:(id)aCheese
|
||||
|
||||
@@ -37,7 +37,6 @@
|
||||
@import "NSCustomView.j"
|
||||
@import "NSEvent.j"
|
||||
@import "NSFont.j"
|
||||
@import "NSFormatter.j"
|
||||
@import "NSIBObjectData.j"
|
||||
@import "NSImage.j"
|
||||
@import "NSImageView.j"
|
||||
@@ -46,7 +45,6 @@
|
||||
@import "NSMenu.j"
|
||||
@import "NSMenuItem.j"
|
||||
@import "NSNibConnector.j"
|
||||
@import "NSNumberFormatter.j"
|
||||
@import "NSObjectController.j"
|
||||
@import "NSOutlineView.j"
|
||||
@import "NSPopUpButton.j"
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
@import "NSAttributedString.j"
|
||||
@import "NSDictionary.j"
|
||||
@import "NSExpression.j"
|
||||
@import "NSFormatter.j"
|
||||
@import "NSMutableString.j"
|
||||
@import "NSNumberFormatter.j"
|
||||
@import "NSSet.j"
|
||||
|
||||
+1
-1
@@ -139,7 +139,7 @@ install_directory=""
|
||||
tmp_zip="/tmp/cappuccino.zip"
|
||||
|
||||
github_user="cappuccino"
|
||||
github_ref="0.9.6"
|
||||
github_ref="v0.9.6-RC1"
|
||||
|
||||
noprompt=""
|
||||
install_capp=""
|
||||
|
||||
Reference in new issue
Block a user