mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-12-02 03:08:22 +00:00
Merge pull request #2173 from daboe01/Fixed--collectionViewDidChangeSelection
Fixed: support for outdated collectionViewDidChangeSelection delegate method
This commit is contained in:
commit
cf93b72edd
2 files changed
+2
-66
No files matched your search
@@ -40,9 +40,8 @@ var CPCollectionViewDelegate_collectionView_acceptDrop_index_dropOperation_
|
||||
CPCollectionViewDelegate_collectionView_dataForItemsAtIndexes_forType_ = 1 << 4,
|
||||
CPCollectionViewDelegate_collectionView_validateDrop_proposedIndex_dropOperation_ = 1 << 5,
|
||||
CPCollectionViewDelegate_collectionView_didDoubleClickOnItemAtIndex_ = 1 << 6,
|
||||
CPCollectionViewDelegate_collectionViewDidChangeSelection_ = 1 << 7,
|
||||
CPCollectionViewDelegate_collectionView_menuForItemAtIndex_ = 1 << 8,
|
||||
CPCollectionViewDelegate_collectionView_draggingViewForItemsAtIndexes_withEvent_offset = 1 << 9;
|
||||
CPCollectionViewDelegate_collectionView_menuForItemAtIndex_ = 1 << 7,
|
||||
CPCollectionViewDelegate_collectionView_draggingViewForItemsAtIndexes_withEvent_offset = 1 << 8;
|
||||
|
||||
|
||||
@protocol CPCollectionViewDelegate <CPObject>
|
||||
@@ -57,7 +56,6 @@ var CPCollectionViewDelegate_collectionView_acceptDrop_index_dropOperation_
|
||||
- (CPMenu)collectionView:(CPCollectionView)collectionView menuForItemAtIndex:(CPInteger)anIndex;
|
||||
- (CPView)collectionView:(CPCollectionView)collectionView dragginViewForItemsAtIndexes:(CPIndexSet)indexes withEvent:(CPEvent)event offset:(CGPoint)dragImageOffset;
|
||||
- (void)collectionView:(CPCollectionView)collectionView didDoubleClickOnItemAtIndex:(int)index;
|
||||
- (void)collectionViewDidChangeSelection:(CPCollectionView)collectionView;
|
||||
|
||||
@end
|
||||
|
||||
@@ -71,10 +69,6 @@ var CPCollectionViewDelegate_collectionView_acceptDrop_index_dropOperation_
|
||||
|
||||
@par Delegate Methods
|
||||
|
||||
@delegate - (void)collectionViewDidChangeSelection:(CPCollectionView)collectionView;
|
||||
DEPRECATED: Please do not use.
|
||||
@param collectionView the collection view who's selection changed
|
||||
|
||||
@delegate - (void)collectionView:(CPCollectionView)collectionView didDoubleClickOnItemAtIndex:(int)index;
|
||||
Called when the user double-clicks on an item in the collection view.
|
||||
@param collectionView the collection view that received the double-click
|
||||
@@ -236,9 +230,6 @@ var HORIZONTAL_MARGIN = 2;
|
||||
if ([_delegate respondsToSelector:@selector(collectionView:didDoubleClickOnItemAtIndex:)])
|
||||
_implementedDelegateMethods |= CPCollectionViewDelegate_collectionView_didDoubleClickOnItemAtIndex_;
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(collectionViewDidChangeSelection:)])
|
||||
_implementedDelegateMethods |= CPCollectionViewDelegate_collectionViewDidChangeSelection_;
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(collectionView:menuForItemAtIndex:)])
|
||||
_implementedDelegateMethods |= CPCollectionViewDelegate_collectionView_menuForItemAtIndex_;
|
||||
|
||||
@@ -473,12 +464,6 @@ var HORIZONTAL_MARGIN = 2;
|
||||
|
||||
var binderClass = [[self class] _binderClassForBinding:@"selectionIndexes"];
|
||||
[[binderClass getBinding:@"selectionIndexes" forObject:self] reverseSetValueFor:@"selectionIndexes"];
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(collectionViewDidChangeSelection:)])
|
||||
{
|
||||
CPLog.warn("The delegate method collectionViewDidChangeSelection: is deprecated and will be removed in a future version, please bind to selectionIndexes instead.");
|
||||
[_delegate collectionViewDidChangeSelection:self];
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -1514,17 +1499,6 @@ Not supported. Use -collectionView:dataForItemsAtIndexes:fortype:
|
||||
return [_delegate collectionView:self didDoubleClickOnItemAtIndex:index];
|
||||
}
|
||||
|
||||
/*!
|
||||
@ignore
|
||||
Call delegate collectionViewDidChangeSelection
|
||||
*/
|
||||
- (void)_sendDelegateCollectionViewDidChangeSelection:(CPCollectionView)collectionView
|
||||
{
|
||||
if (!(_implementedDelegateMethods & CPCollectionViewDelegate_collectionViewDidChangeSelection_))
|
||||
return;
|
||||
|
||||
return [_delegate collectionViewDidChangeSelection:self];
|
||||
}
|
||||
|
||||
/*!
|
||||
@ignore
|
||||
|
||||
@@ -13,12 +13,6 @@
|
||||
_globalResults = nil;
|
||||
}
|
||||
|
||||
// delegate method
|
||||
- (void)collectionViewDidChangeSelection:(CPCollectionView)aCollectionView
|
||||
{
|
||||
_globalResults = "selection changed: " + [[aCollectionView selectionIndexes] count];
|
||||
}
|
||||
|
||||
- (void)testItemPrototypeActuallyReturnsTheItemPrototype
|
||||
{
|
||||
var itemPrototype = [[CPCollectionViewItem alloc] init];
|
||||
@@ -57,38 +51,6 @@
|
||||
[self assert:[collectionView reloadContentCallCount] equals:reloadContentCount + 1 message:@"subsequent calls to setContent should have called reloadContent once"];
|
||||
}
|
||||
|
||||
- (void)testCallCollectionViewDidChangeSelectionDelegateMethod
|
||||
{
|
||||
var content1 = ["a", "b", "c"],
|
||||
content2 = ["d", "e", "f"];
|
||||
|
||||
[_collectionView setSelectable:YES];
|
||||
[_collectionView setDelegate:self];
|
||||
[_collectionView setContent:content1];
|
||||
[_collectionView setSelectionIndexes:[CPIndexSet indexSetWithIndex:0]];
|
||||
// the first time the delegate does get called
|
||||
[self assert:"selection changed: 1" equals:_globalResults];
|
||||
_globalResults = nil;
|
||||
|
||||
// setContent: by itself should not affect the selection.
|
||||
[_collectionView setContent:content1];
|
||||
[self assert:nil equals:_globalResults];
|
||||
// Manually clear the selection.
|
||||
[_collectionView setSelectionIndexes:[CPIndexSet indexSet]];
|
||||
_globalResults = nil;
|
||||
|
||||
|
||||
// now lets change the contents
|
||||
[_collectionView setContent:content2];
|
||||
// we set the selection to 0 again, but on the NEW content
|
||||
[_collectionView setSelectionIndexes:[CPIndexSet indexSetWithIndex:0]];
|
||||
[self assert:"selection changed: 1" equals:_globalResults];
|
||||
|
||||
_globalResults = nil;
|
||||
[_collectionView setSelectionIndexes:[CPIndexSet indexSetWithIndex:1]];
|
||||
[self assert:"selection changed: 1" equals:_globalResults];
|
||||
}
|
||||
|
||||
- (void)testSelectionIndexes
|
||||
{
|
||||
[_collectionView setSelectionIndexes:[CPIndexSet indexSetWithIndex:0]];
|
||||
|
||||
Reference in new issue
Block a user