diff --git a/English.lproj/PXPatternEditor.xib b/English.lproj/PXPatternEditor.xib
index 6c881875..5983968e 100644
--- a/English.lproj/PXPatternEditor.xib
+++ b/English.lproj/PXPatternEditor.xib
@@ -213,7 +213,6 @@
{{1, 144}, {233, 15}}
-
_NS:3883
NO
1
@@ -353,6 +352,14 @@
50
+
content: arrangedObjects
@@ -587,7 +594,7 @@
- 63
+ 64
@@ -635,11 +642,16 @@
+ NSCollectionView
PXPatternEditorView
NSArrayController
NSScrollView
+
+ collectionView
+ NSCollectionView
+
editorView
PXPatternEditorView
diff --git a/Pixen Application/Tools/Patterns/PXPatternEditorController.h b/Pixen Application/Tools/Patterns/PXPatternEditorController.h
index b6361d8f..0c2c6c60 100755
--- a/Pixen Application/Tools/Patterns/PXPatternEditorController.h
+++ b/Pixen Application/Tools/Patterns/PXPatternEditorController.h
@@ -12,6 +12,8 @@
}
@property (nonatomic, strong) IBOutlet NSArrayController *patternsController;
+
+@property (nonatomic, weak) IBOutlet NSCollectionView *collectionView;
@property (nonatomic, weak) IBOutlet NSScrollView *scrollView;
@property (nonatomic, weak) IBOutlet PXPatternEditorView *editorView;
diff --git a/Pixen Application/Tools/Patterns/PXPatternEditorController.m b/Pixen Application/Tools/Patterns/PXPatternEditorController.m
index 315e7d21..da355b3b 100755
--- a/Pixen Application/Tools/Patterns/PXPatternEditorController.m
+++ b/Pixen Application/Tools/Patterns/PXPatternEditorController.m
@@ -14,7 +14,7 @@
@implementation PXPatternEditorController
-@synthesize patternsController, scrollView, editorView;
+@synthesize patternsController, collectionView, scrollView, editorView;
+ (id)sharedController
{
@@ -30,6 +30,8 @@ + (id)sharedController
- (void)awakeFromNib
{
+ [self.collectionView addObserver:self forKeyPath:@"selectionIndexes" options:0 context:NULL];
+
SBCenteringClipView *clip = [[SBCenteringClipView alloc] initWithFrame:[[scrollView contentView] frame]];
[clip setBackgroundColor:[NSColor lightGrayColor]];
[clip setCopiesOnScroll:NO];
@@ -133,11 +135,16 @@ - (void)deleteKeyPressedInCollectionView:(NSCollectionView *)view
contextInfo:nil];
}
-- (void)patternItemWasDoubleClicked:(PXPatternItem *)item
+- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
-#warning TODO: single click
- PXPattern *pattern = [item representedObject];
- [self setPattern:pattern];
+ if ([keyPath isEqualToString:@"selectionIndexes"]) {
+ NSUInteger index = [[self.collectionView selectionIndexes] firstIndex];
+
+ if (index != NSNotFound) {
+ PXPattern *pattern = [[patternsController arrangedObjects] objectAtIndex:index];
+ [self setPattern:pattern];
+ }
+ }
}
- (void)addPattern:(PXPattern *)pattern
@@ -167,6 +174,7 @@ - (void)removePattern:(PXPattern *)pattern
- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
+ [collectionView removeObserver:self forKeyPath:@"selectionIndexes"];
}
- (BOOL)collectionView:(NSCollectionView *)collectionView writeItemsAtIndexes:(NSIndexSet *)indexes toPasteboard:(NSPasteboard *)pasteboard