diff --git a/AddIns/ICSharpCode.SharpDevelop.addin b/AddIns/ICSharpCode.SharpDevelop.addin index 670c86c37e..e08db5d123 100755 --- a/AddIns/ICSharpCode.SharpDevelop.addin +++ b/AddIns/ICSharpCode.SharpDevelop.addin @@ -1252,36 +1252,35 @@ </MenuItem> <!-- END File menu --> <MenuItem id = "Edit" label = "${res:XML.MainMenu.EditMenu}" type="Menu"> + <!-- Do not specify shortcuts for built-in commands, those are bound automatically by WPF. + The shortcuts work correctly in WinForms pads (e.g. label edit in tree view in WinForms project pad) + only if they are not explicitly specified in the menu. + --> <MenuItem id = "Undo" label = "${res:XML.MainMenu.EditMenu.Undo}" icon = "Icons.16x16.UndoIcon" type = "Item" - shortcut = "Control|Z" command = "Undo"/> <MenuItem id = "Redo" label = "${res:XML.MainMenu.EditMenu.Redo}" icon = "Icons.16x16.RedoIcon" type = "Item" - shortcut = "Control|Y" command = "Redo"/> <MenuItem id = "Separator1" type = "Separator" /> <MenuItem id = "Cut" label = "${res:XML.MainMenu.EditMenu.Cut}" icon = "Icons.16x16.CutIcon" type = "Item" - shortcut = "Control|X" command = "Cut"/> <MenuItem id = "Copy" label = "${res:XML.MainMenu.EditMenu.Copy}" icon = "Icons.16x16.CopyIcon" type = "Item" - shortcut = "Control|C" command = "Copy"/> <MenuItem id = "Paste" label = "${res:XML.MainMenu.EditMenu.Paste}" icon = "Icons.16x16.PasteIcon" type = "Item" - shortcut = "Control|V" command = "Paste"/> <MenuItem id = "Delete" label = "${res:XML.MainMenu.EditMenu.Delete}" @@ -1312,7 +1311,6 @@ <MenuItem id = "SelectAll" label = "${res:XML.MainMenu.EditMenu.SelectAll}" type = "Item" - shortcut = "Control|A" command = "SelectAll"/> <MenuItem id = "Separator4" type = "Separator" /> <ComplexCondition action="Disable"> diff --git a/src/Main/Base/Project/Src/Util/SDWindowsFormsHost.cs b/src/Main/Base/Project/Src/Util/SDWindowsFormsHost.cs index c718f2c861..2ce68e58ff 100644 --- a/src/Main/Base/Project/Src/Util/SDWindowsFormsHost.cs +++ b/src/Main/Base/Project/Src/Util/SDWindowsFormsHost.cs @@ -44,21 +44,26 @@ namespace ICSharpCode.SharpDevelop.Gui void AddBinding<T>(ICommand command, Action<T> execute, Predicate<T> canExecute) where T : class { ExecutedRoutedEventHandler onExected = (sender, e) => { - var cbh = GetInterface<T>(); - if (cbh != null) { - e.Handled = true; - if (canExecute(cbh)) - execute(cbh); + if (e.Command == command) { + var cbh = GetInterface<T>(); + if (cbh != null) { + e.Handled = true; + if (canExecute(cbh)) + execute(cbh); + } } }; CanExecuteRoutedEventHandler onCanExecute = (sender, e) => { - var cbh = GetInterface<T>(); - if (cbh != null) { - e.Handled = true; - e.CanExecute = canExecute(cbh); + if (e.Command == command) { + var cbh = GetInterface<T>(); + if (cbh != null) { + e.Handled = true; + e.CanExecute = canExecute(cbh); + } } }; - this.CommandBindings.Add(new CommandBinding(command, onExected, onCanExecute)); + CommandManager.AddCanExecuteHandler(this, onCanExecute); + CommandManager.AddExecutedHandler(this, onExected); } #endregion