Browse Source

Fix SD2-1671 - Delete key is processed both by Windows Forms and WPF

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@5928 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
pull/1/head
Daniel Grunwald 15 years ago
parent
commit
ae955286f2
  1. 10
      AddIns/ICSharpCode.SharpDevelop.addin
  2. 7
      src/Main/Base/Project/Src/Util/SDWindowsFormsHost.cs

10
AddIns/ICSharpCode.SharpDevelop.addin

@ -1252,36 +1252,35 @@ @@ -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 @@ @@ -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">

7
src/Main/Base/Project/Src/Util/SDWindowsFormsHost.cs

@ -44,21 +44,26 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -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) => {
if (e.Command == command) {
var cbh = GetInterface<T>();
if (cbh != null) {
e.Handled = true;
if (canExecute(cbh))
execute(cbh);
}
}
};
CanExecuteRoutedEventHandler onCanExecute = (sender, e) => {
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

Loading…
Cancel
Save