• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Services Menu problems
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Services Menu problems


  • Subject: Services Menu problems
  • From: Steve Gehrman <email@hidden>
  • Date: Sun, 25 Nov 2001 20:58:22 -0800

Having problems getting the services menu working. My biggest problem is figuring out what each application expects as data.

For example TextEdit Open File and Open Selection. I tried passing a path using NSStringPboardType, but TextEdit said it couldn't open (null).

Also DiskCopy has a Mount Image services menu. I can get it to enable, but It also doesn't work. I must be putting the data in the pasteboard incorrectly somehow.

Here's my code, All the services menu items become enabled, but there is something wrong with the data I'm putting in the pasteboard.

-steve

- (id)validRequestorForSendType:(NSString *)sendType returnType:(NSString *)returnType;
{
if ([sendType isEqual:NSFilenamesPboardType] || [sendType isEqual:NSStringPboardType])
{
if ([self numItemsSelected])
return self;
}

return nil;
}

- (BOOL)writeSelectionToPasteboard:(NSPasteboard *)pboard types:(NSArray *)types
{
if ([types containsObject:NSFilenamesPboardType] || [types containsObject:NSStringPboardType])
{
NSArray *typesDeclared = [NSArray arrayWithObjects:NSFilenamesPboardType, NSStringPboardType, nil];
[pboard declareTypes:typesDeclared owner:self];

return YES;
}

return NO;
}

- (void)pasteboard:(NSPasteboard *)pboard provideDataForType:(NSString *)type
{
NSArray* tTypes;

if ([type isEqualToString:NSFilenamesPboardType])
{
NSArray* items = [self getSelectedDescs:RESOLVEPREF];
int i, cnt = [items count];
NSMutableArray* pathsArray = [NSMutableArray array];

for (i=0;i<cnt;i++)
[pathsArray addObject:[[items objectAtIndex:i] path]];

tTypes = [NSArray arrayWithObject:NSFilenamesPboardType];
[pboard declareTypes: tTypes owner:nil];

[pboard setPropertyList:pathsArray forType:NSFilenamesPboardType];
}
else if ([type isEqualToString:NSStringPboardType])
{
FileDesc* desc = [self getFirstSelectedDesc:RESOLVEPREF];

if (desc)
{
tTypes = [NSArray arrayWithObject:NSStringPboardType];
[pboard declareTypes: tTypes owner:nil];

[pboard setString:[desc path] forType:NSStringPboardType];
}
}
}


  • Follow-Ups:
    • Re: Services Menu problems
      • From: Ondra Cada <email@hidden>
  • Prev by Date: Controller knowing about an event
  • Next by Date: Re: NSCalendarDate from plist
  • Previous by thread: Re: Controller knowing about an event
  • Next by thread: Re: Services Menu problems
  • Index(es):
    • Date
    • Thread