diff options
Diffstat (limited to 'main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/Command.cs')
-rw-r--r-- | main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/Command.cs | 62 |
1 files changed, 57 insertions, 5 deletions
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/Command.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/Command.cs index 5bac1ff279..9a0a69b78d 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/Command.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/Command.cs @@ -95,10 +95,39 @@ namespace MonoDevelop.Components.Commands KeyBindingChanged (this, new KeyBindingChangedEventArgs (this, oldKeyBinding)); } } - + + string[] alternateAccelKeys; + KeyBinding[] alternateKeyBindings; + static readonly KeyBinding[] emptyBindings = new KeyBinding[0]; + + public string[] AlternateAccelKeys { + get { return alternateAccelKeys; } + set { + var oldKeybindings = alternateKeyBindings; + if (value == null || value.Length == 0) { + alternateKeyBindings = null; + } else { + alternateKeyBindings = new KeyBinding[value.Length]; + for (int i = 0; i < value.Length; i++) { + KeyBinding b; + KeyBinding.TryParse (value[i], out b); + alternateKeyBindings [i] = b; + } + } + alternateAccelKeys = value; + if (AlternateKeyBindingChanged != null) + AlternateKeyBindingChanged (this, new AlternateKeyBindingChangedEventArgs (this, oldKeybindings)); + } + } + public KeyBinding KeyBinding { get { return binding; } } + + public KeyBinding[] AlternateKeyBindings { + get { return alternateKeyBindings ?? emptyBindings; } + } + public bool DisabledVisible { get { return disabledVisible; } @@ -116,26 +145,49 @@ namespace MonoDevelop.Components.Commands } public event KeyBindingChangedEventHandler KeyBindingChanged; + public event EventHandler<AlternateKeyBindingChangedEventArgs> AlternateKeyBindingChanged; } - public class KeyBindingChangedEventArgs { + public class KeyBindingChangedEventArgs : EventArgs + { public KeyBindingChangedEventArgs (Command command, KeyBinding oldKeyBinding) { OldKeyBinding = oldKeyBinding; Command = command; } - + public Command Command { get; private set; } - + public KeyBinding OldKeyBinding { get; private set; } - + public KeyBinding NewKeyBinding { get { return Command.KeyBinding; } } } + + public class AlternateKeyBindingChangedEventArgs : EventArgs + { + public AlternateKeyBindingChangedEventArgs (Command command, KeyBinding[] oldKeyBinding) + { + OldKeyBinding = oldKeyBinding; + Command = command; + } + + public Command Command { + get; private set; + } + + public KeyBinding[] OldKeyBinding { + get; private set; + } + + public KeyBinding[] NewKeyBinding { + get { return Command.AlternateKeyBindings; } + } + } } |