internal bool ProcessKeyEvent (Gdk.EventKey ev)
{
if (!IsEnabled)
return true;
RegisterUserInteraction ();
bool complete;
KeyboardShortcut[] accels = KeyBindingManager.AccelsFromKey (ev, out complete);
if (!complete) {
// incomplete accel
NotifyIncompleteKeyPressed (ev);
return true;
}
List<Command> commands = null;
KeyBinding binding;
bool isChord;
bool result;
if (CanUseBinding (chords, accels, out binding, out isChord)) {
commands = bindings.Commands (binding);
result = true;
chords = null;
chord = null;
} else if (isChord) {
chord = KeyBindingManager.AccelLabelFromKey (ev);
chords = accels;
return true;
} else if (chords != null) {
// Note: The user has entered a valid chord but the accel was invalid.
if (KeyBindingFailed != null) {
string accel = KeyBindingManager.AccelLabelFromKey (ev);
KeyBindingFailed (this, new KeyBindingFailedEventArgs (GettextCatalog.GetString ("The key combination ({0}, {1}) is not a command.", chord, accel)));
}
chords = null;
chord = null;
return true;
} else {
chords = null;
chord = null;
NotifyKeyPressed (ev);
return false;
}
var toplevelFocus = IdeApp.Workbench.HasToplevelFocus;
bool bypass = false;
for (int i = 0; i < commands.Count; i++) {
CommandInfo cinfo = GetCommandInfo (commands[i].Id, new CommandTargetRoute ());
if (cinfo.Bypass) {
bypass = true;
continue;
}
if (cinfo.Enabled && cinfo.Visible && DispatchCommand (commands[i].Id, CommandSource.Keybinding))
return result;
}
// The command has not been handled.
// If there is at least a handler that sets the bypass flag, allow gtk to execute the default action
if (commands.Count > 0 && !bypass) {
result = true;
} else {
result = false;
NotifyKeyPressed (ev);
}
chords = null;
return result;
}