Browse Source

Allow keyboard shortcuts to be set for file tab strip menu.

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. As a result the MenuCommand's
AddGestureToInputBindingOwner method refused to register any
keyboard shortcuts assigned to 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.

And make "Alt-Shift-L" the default shortcut for the NavigateToFileInProjectBrowser menu command.

Cherry picked from pull request #729
pull/746/head
nik 10 years ago committed by Matt Ward
parent
commit
dac29c5a29
  1. 1
      src/Main/Base/Project/ICSharpCode.SharpDevelop.addin
  2. 9
      src/Main/Base/Project/Src/Commands/FileTabStripCommands.cs
  3. 23
      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}"

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

@ -105,9 +105,14 @@ namespace ICSharpCode.SharpDevelop.Commands.TabStrip @@ -105,9 +105,14 @@ 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;
}

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

@ -114,12 +114,31 @@ namespace ICSharpCode.Core.Presentation @@ -114,12 +114,31 @@ 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);
}
static ContextMenu CreateContextMenu(MenuCreateContext context, object owner, string addInTreePath)
{
IList items = CreateUnexpandedMenuItems(
context,
AddInTree.BuildItems<MenuItemDescriptor>(addInTreePath, owner, false));
return CreateContextMenu(items);
}
public static ContextMenu ShowContextMenu(UIElement parent, object owner, string addInTreePath)
{
ContextMenu menu = new ContextMenu();

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