Permalink
Browse files

export patterns

  • Loading branch information...
1 parent f6b37a8 commit b3105ce7770559b3ad15f16730d7ba944786a696 @mattrajca mattrajca committed Feb 24, 2013
Showing with 13 additions and 3 deletions.
  1. +13 −3 Pixen Application/Tools/Patterns/PXPatternEditorController.m
@@ -30,6 +30,8 @@ + (id)sharedController
- (void)awakeFromNib
{
+ [self.collectionView registerForDraggedTypes:@[ NSFilesPromisePboardType ]];
+ [self.collectionView setDraggingSourceOperationMask:NSDragOperationCopy forLocal:NO];
[self.collectionView addObserver:self forKeyPath:@"selectionIndexes" options:0 context:NULL];
[editorView setDelegate:self];
@@ -189,13 +191,21 @@ - (void)dealloc
[collectionView removeObserver:self forKeyPath:@"selectionIndexes"];
}
-- (BOOL)collectionView:(NSCollectionView *)collectionView writeItemsAtIndexes:(NSIndexSet *)indexes toPasteboard:(NSPasteboard *)pasteboard
+- (NSArray *)collectionView:(NSCollectionView *)collectionView namesOfPromisedFilesDroppedAtDestination:(NSURL *)dropURL forDraggedItemsAtIndexes:(NSIndexSet *)indexes
{
NSUInteger index = [indexes firstIndex];
PXPattern *pattern = [[patternsController arrangedObjects] objectAtIndex:index];
- [pasteboard declareTypes:[NSArray arrayWithObject:PXPatternPboardType] owner:self];
- [pasteboard setData:[NSKeyedArchiver archivedDataWithRootObject:pattern] forType:PXPatternPboardType];
+ NSData *data = [NSKeyedArchiver archivedDataWithRootObject:pattern];
+ [data writeToURL:[dropURL URLByAppendingPathComponent:@"Pattern.pxpattern"] atomically:YES];
+
+ return [NSArray arrayWithObject:@"Pattern.pxpattern"];
+}
+
+- (BOOL)collectionView:(NSCollectionView *)collectionView writeItemsAtIndexes:(NSIndexSet *)indexes toPasteboard:(NSPasteboard *)pasteboard
+{
+ [pasteboard declareTypes:[NSArray arrayWithObjects:NSFilesPromisePboardType, nil] owner:self];
+ [pasteboard setPropertyList:@[ @"pxpattern" ] forType:NSFilesPromisePboardType];
return YES;
}

0 comments on commit b3105ce

Please sign in to comment.