static object GetCommandID(CarbonHICommand cmdEvent) { object cmdID; commands.TryGetValue(cmdEvent.CommandID, out cmdID); return(cmdID); }
internal static void RunMenuCommand(CarbonCommandID commandID) { var item = HIToolbox.GetMenuItem((uint)commandID); var cmd = new CarbonHICommand((uint)commandID, item); Carbon.ProcessHICommand(ref cmd); }
static CarbonEventHandlerStatus HandleMenuCommand(IntPtr callRef, IntPtr eventRef, IntPtr userData) { try { CarbonHICommand hiCmd = GetCarbonHICommand(eventRef); uint refCon = HIToolbox.GetMenuItemReferenceConstant(hiCmd.MenuItem); //link commands if (hiCmd.CommandID == linkCommandId) { string url = ""; try { url = linkCommands[(int)refCon]; MacPlatformService.OpenUrl(url); } catch (Exception ex) { Gtk.Application.Invoke(delegate { MonoDevelop.Ide.MessageService.ShowException(ex, MonoDevelop.Core.GettextCatalog.GetString("Could not open the url {0}", url)); }); } DestroyOldMenuObjects(); return(CarbonEventHandlerStatus.Handled); } //normal commands object cmdID = GetCommandID(hiCmd); if (cmdID != null) { if (refCon > 0) { object data = objectsToDestroyOnMenuClose[(int)refCon - 1]; //need to return before we execute the command, so that the menu unhighlights Gtk.Application.Invoke(delegate { manager.DispatchCommand(cmdID, data, CommandSource.MainMenu); }); } else { Gtk.Application.Invoke(delegate { manager.DispatchCommand(cmdID, CommandSource.MainMenu); }); } DestroyOldMenuObjects(); return(CarbonEventHandlerStatus.Handled); } } catch (Exception ex) { MonoDevelop.Core.LoggingService.LogError("Unhandled error handling menu command", ex); } return(CarbonEventHandlerStatus.NotHandled); }
internal static void RunMenuCommand (CarbonCommandID commandID) { var item = HIToolbox.GetMenuItem ((uint)commandID); var cmd = new CarbonHICommand ((uint)commandID, item); Carbon.ProcessHICommand (ref cmd); }
static object GetCommandID (CarbonHICommand cmdEvent) { object cmdID; commands.TryGetValue (cmdEvent.CommandID, out cmdID); return cmdID; }