diff options
author | David Karlaš <david.karlas@xamarin.com> | 2014-06-19 14:12:16 +0400 |
---|---|---|
committer | David Karlaš <david.karlas@xamarin.com> | 2014-06-19 14:12:16 +0400 |
commit | 8e05ed18f517fab748dd17215a450ee4569b8e75 (patch) | |
tree | 1e2dd086cdf8e9240c834bb2e023742af08d27fe /main/src | |
parent | bc10d363d2eb273be24514e1330e911bf29acdeb (diff) |
[Ide] Fixing disabled OSX ContextMenus in Modal dialogs(Bug 20683)
Diffstat (limited to 'main/src')
7 files changed, 23 insertions, 17 deletions
diff --git a/main/src/addins/MacPlatform/MacMenu/MDMenu.cs b/main/src/addins/MacPlatform/MacMenu/MDMenu.cs index c181434c06..6a10f51b51 100644 --- a/main/src/addins/MacPlatform/MacMenu/MDMenu.cs +++ b/main/src/addins/MacPlatform/MacMenu/MDMenu.cs @@ -38,7 +38,7 @@ namespace MonoDevelop.MacIntegration.MacMenu { static readonly string servicesID = (string) CommandManager.ToCommandId (MacIntegrationCommands.Services); - public MDMenu (CommandManager manager, CommandEntrySet ces) + public MDMenu (CommandManager manager, CommandEntrySet ces, CommandSource commandSource, object initialCommandTarget) { this.WeakDelegate = this; @@ -59,7 +59,7 @@ namespace MonoDevelop.MacIntegration.MacMenu var subset = ce as CommandEntrySet; if (subset != null) { - AddItem (new MDSubMenuItem (manager, subset)); + AddItem (new MDSubMenuItem (manager, subset, commandSource, initialCommandTarget)); continue; } @@ -86,7 +86,7 @@ namespace MonoDevelop.MacIntegration.MacMenu continue; } - AddItem (new MDMenuItem (manager, ce, acmd)); + AddItem (new MDMenuItem (manager, ce, acmd, commandSource, initialCommandTarget)); } } diff --git a/main/src/addins/MacPlatform/MacMenu/MDMenuItem.cs b/main/src/addins/MacPlatform/MacMenu/MDMenuItem.cs index 2ab9ed4e5e..a7b135bdb3 100644 --- a/main/src/addins/MacPlatform/MacMenu/MDMenuItem.cs +++ b/main/src/addins/MacPlatform/MacMenu/MDMenuItem.cs @@ -45,11 +45,15 @@ namespace MonoDevelop.MacIntegration.MacMenu CommandManager manager; bool isArrayItem; + object initialCommandTarget; + CommandSource commandSource; - public MDMenuItem (CommandManager manager, CommandEntry ce, ActionCommand command) + public MDMenuItem (CommandManager manager, CommandEntry ce, ActionCommand command, CommandSource commandSource, object initialCommandTarget) { this.ce = ce; this.manager = manager; + this.initialCommandTarget = initialCommandTarget; + this.commandSource = commandSource; isArrayItem = command.CommandArray; @@ -66,9 +70,9 @@ namespace MonoDevelop.MacIntegration.MacMenu //if the command opens a modal subloop, give cocoa a chance to unhighlight the menu item GLib.Timeout.Add (1, () => { if (a != null) { - manager.DispatchCommand (ce.CommandId, a.Info.DataItem, CommandSource.MainMenu); + manager.DispatchCommand (ce.CommandId, a.Info.DataItem, initialCommandTarget, commandSource); } else { - manager.DispatchCommand (ce.CommandId, CommandSource.MainMenu); + manager.DispatchCommand (ce.CommandId, null, initialCommandTarget, commandSource); } return false; }); @@ -84,7 +88,7 @@ namespace MonoDevelop.MacIntegration.MacMenu public void Update (MDMenu parent, ref NSMenuItem lastSeparator, ref int index) { - var info = manager.GetCommandInfo (ce.CommandId); + var info = manager.GetCommandInfo (ce.CommandId, new CommandTargetRoute (initialCommandTarget)); if (!isArrayItem) { SetItemValues (this, info); @@ -148,10 +152,12 @@ namespace MonoDevelop.MacIntegration.MacMenu public CommandInfo Info; } - static void SetItemValues (NSMenuItem item, CommandInfo info) + void SetItemValues (NSMenuItem item, CommandInfo info) { item.SetTitleWithMnemonic (GetCleanCommandText (info)); - item.Enabled = !IsGloballyDisabled && info.Enabled; + if (commandSource != CommandSource.ContextMenu) { + item.Enabled = !IsGloballyDisabled && info.Enabled; + } item.Hidden = !info.Visible; SetAccel (item, info.AccelKey); diff --git a/main/src/addins/MacPlatform/MacMenu/MDSubMenuItem.cs b/main/src/addins/MacPlatform/MacMenu/MDSubMenuItem.cs index 84de750319..547d788ec5 100644 --- a/main/src/addins/MacPlatform/MacMenu/MDSubMenuItem.cs +++ b/main/src/addins/MacPlatform/MacMenu/MDSubMenuItem.cs @@ -34,11 +34,11 @@ namespace MonoDevelop.MacIntegration.MacMenu { CommandEntrySet ces; - public MDSubMenuItem (CommandManager manager, CommandEntrySet ces) + public MDSubMenuItem (CommandManager manager, CommandEntrySet ces, CommandSource commandSource = CommandSource.MainMenu, object initialCommandTarget = null) { this.ces = ces; - this.Submenu = new MDMenu (manager, ces); + this.Submenu = new MDMenu (manager, ces, commandSource, initialCommandTarget); this.Title = this.Submenu.Title; } diff --git a/main/src/addins/MacPlatform/MacPlatform.cs b/main/src/addins/MacPlatform/MacPlatform.cs index 47f89932f9..8800f13819 100644 --- a/main/src/addins/MacPlatform/MacPlatform.cs +++ b/main/src/addins/MacPlatform/MacPlatform.cs @@ -203,12 +203,12 @@ namespace MonoDevelop.MacIntegration return map; } - public override bool ShowContextMenu (CommandManager commandManager, Gtk.Widget widget, double x, double y, CommandEntrySet entrySet) + public override bool ShowContextMenu (CommandManager commandManager, Gtk.Widget widget, double x, double y, CommandEntrySet entrySet, object initialCommandTarget = null) { Gtk.Application.Invoke (delegate { // Explicitly release the grab because the menu is shown on the mouse position, and the widget doesn't get the mouse release event Gdk.Pointer.Ungrab (Gtk.Global.CurrentEventTime); - var menu = new MDMenu (commandManager, entrySet); + var menu = new MDMenu (commandManager, entrySet, CommandSource.ContextMenu, initialCommandTarget); var nsview = MacInterop.GtkQuartz.GetView (widget); var toplevel = widget.Toplevel as Gtk.Window; int trans_x, trans_y; diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/CommandManager.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/CommandManager.cs index 3421602a1a..d83f3a6e54 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/CommandManager.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/CommandManager.cs @@ -709,7 +709,7 @@ namespace MonoDevelop.Components.Commands { if (Platform.IsMac) { parent.GrabFocus (); - return DesktopService.ShowContextMenu (this, parent, evt.X, evt.Y, entrySet); + return DesktopService.ShowContextMenu (this, parent, evt.X, evt.Y, entrySet, initialCommandTarget); } else { var menu = CreateMenu (entrySet); if (menu != null) diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Desktop/PlatformService.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Desktop/PlatformService.cs index 5b8f3462c1..42b5deb2e8 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Desktop/PlatformService.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Desktop/PlatformService.cs @@ -329,7 +329,7 @@ namespace MonoDevelop.Ide.Desktop } public virtual bool ShowContextMenu (MonoDevelop.Components.Commands.CommandManager commandManager, - Gtk.Widget widget, double x, double y, MonoDevelop.Components.Commands.CommandEntrySet entrySet) + Gtk.Widget widget, double x, double y, MonoDevelop.Components.Commands.CommandEntrySet entrySet, object initialCommandTarget = null) { return false; } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/DesktopService.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/DesktopService.cs index a5cdbf6fc8..86a1e89470 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/DesktopService.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/DesktopService.cs @@ -200,9 +200,9 @@ namespace MonoDevelop.Ide } public static bool ShowContextMenu (MonoDevelop.Components.Commands.CommandManager commandManager, - Gtk.Widget widget, double x, double y, MonoDevelop.Components.Commands.CommandEntrySet entrySet) + Gtk.Widget widget, double x, double y, MonoDevelop.Components.Commands.CommandEntrySet entrySet, object initialCommandTarget = null) { - return PlatformService.ShowContextMenu (commandManager, widget, x, y, entrySet); + return PlatformService.ShowContextMenu (commandManager, widget, x, y, entrySet, initialCommandTarget); } public static bool SetGlobalMenu (MonoDevelop.Components.Commands.CommandManager commandManager, |