////////////////////////////////////////////////////////////////////////////// #region Scene key handling private bool SceneKeyDownHandler(KeyCode key, CModifiers modifiers) { CBinding binding; CShortCut shortCut = new CShortCut(key, modifiers); if (CBindings.FindBinding(shortCut, out binding)) { return(ExecCommand(binding.cmdKeyDown)); } return(false); }
public static bool TryParse(string token, out CShortCut shortCut) { string[] tokens = token.Split('+'); CModifiers modifiers = 0; if (tokens.Length > 1) { for (int i = 0; i < tokens.Length - 1; ++i) { string name = tokens[i].ToLower(); if (name == "ctrl") { modifiers |= CModifiers.Control; } else if (name == "shift") { modifiers |= CModifiers.Shift; } else if (name == "alt") { modifiers |= CModifiers.Alt; } else if (name == "cmd" || name == "command") { modifiers |= CModifiers.Command; } else { shortCut = default(CShortCut); return(false); } } } string keyName = tokens[tokens.Length - 1].ToLower(); KeyCode key; if (!CBindings.TryParse(keyName, out key)) { shortCut = default(CShortCut); return(false); } shortCut = new CShortCut(key, modifiers); return(true); }
private static CModifiers GetModifiers(CEvent evt) { CModifiers modifiers = 0; if (evt.alt) { modifiers |= CModifiers.Alt; } if (evt.shift) { modifiers |= CModifiers.Shift; } if (evt.control) { modifiers |= CModifiers.Control; } if (evt.command) { modifiers |= CModifiers.Command; } return(modifiers); }
public static bool TryParse(string token, out CShortCut shortCut) { string[] tokens = token.Split('+'); CModifiers modifiers = 0; if (tokens.Length > 1) { for (int i = 0; i < tokens.Length - 1; ++i) { string name = tokens[i].ToLower(); if (name == "ctrl") modifiers |= CModifiers.Control; else if (name == "shift") modifiers |= CModifiers.Shift; else if (name == "alt") modifiers |= CModifiers.Alt; else if (name == "cmd" || name == "command") modifiers |= CModifiers.Command; else { shortCut = default(CShortCut); return false; } } } string keyName = tokens[tokens.Length - 1].ToLower(); KeyCode key; if (!CBindings.TryParse(keyName, out key)) { shortCut = default(CShortCut); return false; } shortCut = new CShortCut(key, modifiers); return true; }
public CShortCut(KeyCode key, CModifiers modifiers) { this.key = key; this.modifiers = modifiers; }
public bool HasModifier(CModifiers modifier) { return((modifiers & modifier) != 0); }
public bool HasModifier(CModifiers modifier) { return (modifiers & modifier) != 0; }
private bool SceneUpDownHandler(KeyCode key, CModifiers modifiers) { CBinding binding; CShortCut shortCut = new CShortCut(key, modifiers); if (CBindings.FindBinding(shortCut, out binding) && binding.cmdKeyUp != null) { return ExecCommand(binding.cmdKeyUp); } return false; }