Sending data from contextual menu plugin to Cocoa app

  • Hi there,
    I'm writing an application that has two separate utilities: a main
    Cocoa app, and a contextual menu item. I'd like the contextual menu
    item to allow the user to select files for processing in the Cocoa
    app; it would deliver the file's path into the Cocoa app.

    However, as I've learned, contextual menu plugins are written in
    straight C (see http://www.mactech.com/articles/mact...ins/index.html
    for a tutorial). Ultimately you get down to the essential problem:
    what C function will take a path name and fork it over to a Cocoa app?

    I hope this is clearly explained... I barely understand hte problem
    well enough to phrase a proper Google search! Further explanation
    forthcoming if required.

    Thanks,
    Aaron.

    --
    Aaron Vegh, Principal
    Innoveghtive Inc.
    P: (647) 477-2690
    C: (905) 924-1220
    www.innoveghtive.com
    www.website-in-a-day.com
  • Le 17 déc. 07 à 15:30, Aaron Vegh a écrit :

    > Hi there,
    > I'm writing an application that has two separate utilities: a main
    > Cocoa app, and a contextual menu item. I'd like the contextual menu
    > item to allow the user to select files for processing in the Cocoa
    > app; it would deliver the file's path into the Cocoa app.
    >
    > However, as I've learned, contextual menu plugins are written in
    > straight C (see http://www.mactech.com/articles/mact...ins/index.html
    > for a tutorial). Ultimately you get down to the essential problem:
    > what C function will take a path name and fork it over to a Cocoa app?
    >
    > I hope this is clearly explained... I barely understand hte problem
    > well enough to phrase a proper Google search! Further explanation
    > forthcoming if required.
    >
    > Thanks,
    > Aaron.
    >

    You can call Cocoa code into a Contextual Menu plugin.

    Just be sure to bracket your Cocoa call into autorelease pool

    ContextualMenuCallBack(args) {
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

    /* You obj-c code here */
    NSTask *task = [NSTask task......];

    [pool release];
    }
  • Salut Jean-Daniel,
    Thanks for your reply! I was wondering if you knew of where I might
    find some official documentation around this technique?

    Cheers,
    Aaron.

    On Dec 17, 2007 10:13 AM, Jean-Daniel Dupas <devlists...> wrote:
    >
    > Le 17 déc. 07 à 15:30, Aaron Vegh a écrit :
    >
    >> Hi there,
    >> I'm writing an application that has two separate utilities: a main
    >> Cocoa app, and a contextual menu item. I'd like the contextual menu
    >> item to allow the user to select files for processing in the Cocoa
    >> app; it would deliver the file's path into the Cocoa app.
    >>
    >> However, as I've learned, contextual menu plugins are written in
    >> straight C (see http://www.mactech.com/articles/mact...ins/index.html
    >> for a tutorial). Ultimately you get down to the essential problem:
    >> what C function will take a path name and fork it over to a Cocoa app?
    >>
    >> I hope this is clearly explained... I barely understand hte problem
    >> well enough to phrase a proper Google search! Further explanation
    >> forthcoming if required.
    >>
    >> Thanks,
    >> Aaron.
    >>
    >
    >
    > You can call Cocoa code into a Contextual Menu plugin.
    >
    > Just be sure to bracket your Cocoa call into autorelease pool
    >
    > ContextualMenuCallBack(args) {
    > NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    >
    > /* You obj-c code here */
    > NSTask *task = [NSTask task......];
    >
    > [pool release];
    > }
    >
    >

    --
    Aaron Vegh, Principal
    Innoveghtive Inc.
    P: (647) 477-2690
    C: (905) 924-1220
    www.innoveghtive.com
    www.website-in-a-day.com
  • Le 17 déc. 07 à 16:17, Aaron Vegh a écrit :

    > Salut Jean-Daniel,
    > Thanks for your reply! I was wondering if you knew of where I might
    > find some official documentation around this technique?
    >
    > Cheers,
    > Aaron.

    Yep

    Introduction to Carbon-Cocoa Integration Guide:
    http://developer.apple.com/documentation/Cocoa/Conceptual/CarbonCocoaDoc/Ca
    rbonCocoaDoc.html


    Look at the "Using Cocoa Functionality in a Carbon Application" chapter.

    Regards
    Jean-Daniel
previous month december 2007 next month
MTWTFSS
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31            
Go to today