+ wxTaskBarIcon*& pTB = (wxTaskBarIcon*&) pData;
+
+ const UInt32 eventClass = GetEventClass(inEvent);
+ const UInt32 eventKind = GetEventKind(inEvent);
+
+ if (eventClass == kEventClassCommand && eventKind == kEventCommandProcess)
+ {
+ MenuRef hMenu = MAC_WXHMENU(pTB->GetCurrentMenu()->GetHMenu());
+ OSStatus result = eventNotHandledErr ;
+
+ HICommand command ;
+ OSErr err;
+
+ err = GetEventParameter(inEvent, kEventParamDirectObject, typeHICommand,
+ NULL, sizeof(HICommand), NULL, &command);
+ wxASSERT(err == noErr);
+
+ MenuItemIndex menuItemIndex;
+ err = GetIndMenuItemWithCommandID(hMenu, command.commandID, 1, NULL, &menuItemIndex);
+ wxASSERT(err == noErr);
+
+
+ MenuCommand id = command.commandID ;
+ wxMenuItem* item = NULL;
+ // for items we don't really control
+ if ( id == kHICommandPreferences )
+ {
+ id = wxApp::s_macPreferencesMenuItemId ;
+
+ wxMenuBar* mbar = wxMenuBar::MacGetInstalledMenuBar() ;
+ if ( mbar )
+ {
+ wxMenu* menu = NULL ;
+ item = mbar->FindItem( id , &menu ) ;
+ }
+ }
+ else if (id != 0)
+ GetMenuItemRefCon( hMenu , menuItemIndex , (UInt32*) &item ) ;
+
+ if ( item )
+ {
+ if (item->IsCheckable())
+ {
+ item->Check( !item->IsChecked() ) ;
+ }
+
+ item->GetMenu()->SendEvent( id , item->IsCheckable() ? item->IsChecked() : -1 ) ;
+ result = noErr ;
+ }
+ return result ;
+ }
+
+ wxASSERT(eventClass == kEventClassApplication && eventKind == kEventAppGetDockTileMenu);
+
+ //set the internal event
+ pTB->SetInternalEvent(inEvent);
+
+ //process the right click event
+ wxTaskBarIconEvent evt(wxEVT_TASKBAR_RIGHT_UP,NULL);
+ pTB->ProcessEvent(evt);
+
+ //set the internal event
+ pTB->SetInternalEvent(NULL);
+
+ return noErr;