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

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

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

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

@ -114,8 +114,28 @@ namespace ICSharpCode.Core.Presentation @@ -114,8 +114,28 @@ namespace ICSharpCode.Core.Presentation
public static ContextMenu CreateContextMenu(object owner, string addInTreePath)
{
IList items = CreateUnexpandedMenuItems(
return CreateContextMenu(
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));
return CreateContextMenu(items);
}

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

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

Loading…
Cancel
Save