Browse Source

Keyboard shortcuts assigned to the file tab strip menu's items (/SharpDevelop/Workbench/OpenFileTab/ContextMenu) were ignored because InputBindingOwner was not set in MenuCreateContext while creating these menu items.

Make AvalonWorkbenchWindow register itself as InputBindingOwner in MenuCreateContext when creating the file tab strip menu items and hence make shortcuts assigned to them work.
pull/729/head
nik 10 years ago
parent
commit
6aad1ae617
  1. 1
      src/Main/Base/Project/ICSharpCode.SharpDevelop.addin
  2. 11
      src/Main/Base/Project/Src/Commands/FileTabStripCommands.cs
  3. 24
      src/Main/ICSharpCode.Core.Presentation/Menu/MenuService.cs
  4. 2
      src/Main/SharpDevelop/Workbench/AvalonWorkbenchWindow.cs

1
src/Main/Base/Project/ICSharpCode.SharpDevelop.addin

@ -1278,6 +1278,7 @@
class = "ICSharpCode.SharpDevelop.Commands.TabStrip.CopyPathName"/> class = "ICSharpCode.SharpDevelop.Commands.TabStrip.CopyPathName"/>
<MenuItem id = "NavigateToFileInProjectBrowser" <MenuItem id = "NavigateToFileInProjectBrowser"
label = "${res:ICSharpCode.SharpDevelop.Commands.TabStrip.NavigateToFileInProjectBrowser}" label = "${res:ICSharpCode.SharpDevelop.Commands.TabStrip.NavigateToFileInProjectBrowser}"
shortcut = "Alt|Shift|L"
class = "ICSharpCode.SharpDevelop.Commands.TabStrip.NavigateToFileInProjectBrowser"/> class = "ICSharpCode.SharpDevelop.Commands.TabStrip.NavigateToFileInProjectBrowser"/>
<MenuItem id = "OpenFolderContainingFileFromTab" <MenuItem id = "OpenFolderContainingFileFromTab"
label = "${res:OpenFileTabEventHandler.FileContainingFolderInExplorer}" label = "${res:OpenFileTabEventHandler.FileContainingFolderInExplorer}"

11
src/Main/Base/Project/Src/Commands/FileTabStripCommands.cs

@ -105,9 +105,16 @@ namespace ICSharpCode.SharpDevelop.Commands.TabStrip
string GetActiveFileName() string GetActiveFileName()
{ {
if ((this.Owner is IWorkbenchWindow) && (((IWorkbenchWindow)this.Owner).ActiveViewContent != null)) { var workbenchWindow = Owner as IWorkbenchWindow;
return (Owner as IWorkbenchWindow).ActiveViewContent.PrimaryFileName; if (workbenchWindow == null)
workbenchWindow = SD.Workbench.ActiveWorkbenchWindow;
if (workbenchWindow != null &&
workbenchWindow.ActiveViewContent != null)
{
return workbenchWindow.ActiveViewContent.PrimaryFileName;
} }
return null; return null;
} }

24
src/Main/ICSharpCode.Core.Presentation/Menu/MenuService.cs

@ -114,12 +114,32 @@ namespace ICSharpCode.Core.Presentation
public static ContextMenu CreateContextMenu(object owner, string addInTreePath) public static ContextMenu CreateContextMenu(object owner, string addInTreePath)
{ {
IList items = CreateUnexpandedMenuItems( return CreateContextMenu(
new MenuCreateContext { ActivationMethod = "ContextMenu" }, new MenuCreateContext { ActivationMethod = "ContextMenu" },
owner,
addInTreePath);
}
public static ContextMenu CreateContextMenu(UIElement inputBindingOwner, object owner, string addInTreePath)
{
return CreateContextMenu(
new MenuCreateContext
{
InputBindingOwner = inputBindingOwner,
ActivationMethod = "ContextMenu"
},
owner,
addInTreePath);
}
private static ContextMenu CreateContextMenu(MenuCreateContext context, object owner, string addInTreePath)
{
IList items = CreateUnexpandedMenuItems(
context,
AddInTree.BuildItems<MenuItemDescriptor>(addInTreePath, owner, false)); AddInTree.BuildItems<MenuItemDescriptor>(addInTreePath, owner, false));
return CreateContextMenu(items); return CreateContextMenu(items);
} }
public static ContextMenu ShowContextMenu(UIElement parent, object owner, string addInTreePath) public static ContextMenu ShowContextMenu(UIElement parent, object owner, string addInTreePath)
{ {
ContextMenu menu = new ContextMenu(); ContextMenu menu = new ContextMenu();

2
src/Main/SharpDevelop/Workbench/AvalonWorkbenchWindow.cs

@ -293,7 +293,7 @@ namespace ICSharpCode.SharpDevelop.Workbench
base.OnApplyTemplate(); base.OnApplyTemplate();
if (this.DragEnabledArea != null) { if (this.DragEnabledArea != null) {
this.DragEnabledArea.ContextMenu = MenuService.CreateContextMenu(this, contextMenuPath); this.DragEnabledArea.ContextMenu = MenuService.CreateContextMenu(this, this, contextMenuPath);
UpdateInfoTip(); // set tooltip UpdateInfoTip(); // set tooltip
} }
} }

Loading…
Cancel
Save