Hi James,

(I sent another bugfix to enable custom menus, the sample code will only work if you update the producer source.)

James E. Hopper schrieb:

is there documentation on how to add a menu? i confess i havent been following the mailing list all that closely.

This is standard carbon stuff. The simplest way is to create a menubar with the help of Interface Builder, and load this menubar in your code.

To load the menubar from the nib-file "testmenubar": (be aware of linebreaks!)

    // install menubar
    IBNibRef menubarNib;
    OSStatus err;

    err = CreateNibReference (CFSTR ("testmenubar"), &menubarNib);

    if (err == noErr)
    {
        err = SetMenuBarFromNib(menubarNib, CFSTR("MenuBar"));
    }

    DisposeNibReference (menubarNib);

Then you'll have to install an application-event-handler to handle the menu-items:

    // Install an application event-handler:
static const EventTypeSpec menueventSpec = {kEventClassCommand, kEventCommandProcess}; OSErr status = InstallApplicationEventHandler(MyApplicationEventHandler, 1, &menueventSpec, NULL, NULL);



The application-event-handler looks like this:

static pascal OSStatus MyApplicationEventHandler(EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void *inUserData)
{
#pragma unused(inHandlerCallRef)


        OSStatus status  = eventNotHandledErr;

        HICommand commandStruct;
GetEventParameter (inEvent, kEventParamDirectObject, typeHICommand, NULL, sizeof(HICommand), NULL, &commandStruct);
        std::cout << "commandID: " << commandStruct.commandID << std::endl;
        
        return status;
}


This stuff is documented at http://developer.apple.com. Search for "carbon" "menu".

I hope this helps a little bit.

Stephan
_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

Reply via email to