bool Editor_keyDown(int key, int keyCode, int modifiers) { enum Selection selection = modifiers & EMGUI_KEY_SHIFT ? DO_SELECTION : NO_SELECTION; int highlightRowStep = getTrackData()->highlightRowStep; if (Emgui_hasKeyboardFocus()) { Editor_update(); return true; } // Update editing of values if (doEditing(key)) return true; switch (key) { case EMGUI_KEY_ARROW_UP : case EMGUI_KEY_ARROW_DOWN : case EMGUI_KEY_ARROW_LEFT : case EMGUI_KEY_ARROW_RIGHT : case EMGUI_KEY_TAB : case EMGUI_KEY_ENTER : { if (is_editing) { endEditing(); if (key == EMGUI_KEY_ENTER) return true; } break; } case EMGUI_KEY_ESC : { cancelEditing(); break; } } switch (key) { // this is a bit hacky but we don't want to have lots of combos in the menus // of arrow keys so this makes it a bit easier case EMGUI_KEY_ARROW_UP : { if (modifiers & EMGUI_KEY_CTRL) onPrevNextKey(true, selection); else if (modifiers & EMGUI_KEY_COMMAND) onBookmarkDir(ARROW_UP, selection); else if (modifiers & EMGUI_KEY_ALT) onRowStep(-highlightRowStep , selection); else onRowStep(-1, selection); break; } case EMGUI_KEY_ARROW_DOWN : { if (modifiers & EMGUI_KEY_CTRL) onPrevNextKey(false, selection); else if (modifiers & EMGUI_KEY_COMMAND) onBookmarkDir(ARROW_DOWN, selection); else if (modifiers & EMGUI_KEY_ALT) onRowStep(highlightRowStep, selection); else onRowStep(1, selection); break; } case EMGUI_KEY_ARROW_LEFT : onTrackSide(ARROW_LEFT, false, selection); break; case EMGUI_KEY_ARROW_RIGHT : onTrackSide(ARROW_RIGHT, false, selection); break; case EMGUI_KEY_TAB : onTab(); break; default : return false; } return true; }
LRESULT ChatControl::onMessageKeyDown(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled) { if (wParam != VK_TAB && !complete.empty()) { complete.clear(); } if (wParam == VK_TAB) { onTab(); } else if (!processHotKey(wParam)) { switch(wParam) { case VK_RETURN: if ((GetKeyState(VK_CONTROL) & 0x8000) || (GetKeyState(VK_MENU) & 0x8000)) { bHandled = FALSE; } else { onSend(); } break; case VK_UP: if ((GetKeyState(VK_MENU) & 0x8000) || (((GetKeyState(VK_CONTROL) & 0x8000) == 0) ^ (BOOLSETTING(USE_CTRL_FOR_LINE_HISTORY) == true))) { //scroll up in chat command history //currently beyond the last command? if (curCommandPosition > 0) { //check whether current command needs to be saved if (curCommandPosition == prevCommands.size()) { AutoArray<TCHAR> messageContents(ctrlMessage.GetWindowTextLength()+2); ctrlMessage.GetWindowText(messageContents, ctrlMessage.GetWindowTextLength()+1); currentCommand = tstring(messageContents); } //replace current chat buffer with current command ctrlMessage.SetWindowText(prevCommands[--curCommandPosition].c_str()); } // move cursor to end of line ctrlMessage.SetSel(ctrlMessage.GetWindowTextLength(), ctrlMessage.GetWindowTextLength()); } else { bHandled = FALSE; } break; case VK_DOWN: if ((GetKeyState(VK_MENU) & 0x8000) || (((GetKeyState(VK_CONTROL) & 0x8000) == 0) ^ (BOOLSETTING(USE_CTRL_FOR_LINE_HISTORY) == true))) { //scroll down in chat command history //currently beyond the last command? if (curCommandPosition + 1 < prevCommands.size()) { //replace current chat buffer with current command ctrlMessage.SetWindowText(prevCommands[++curCommandPosition].c_str()); } else if (curCommandPosition + 1 == prevCommands.size()) { //revert to last saved, unfinished command ctrlMessage.SetWindowText(currentCommand.c_str()); ++curCommandPosition; } // move cursor to end of line ctrlMessage.SetSel(ctrlMessage.GetWindowTextLength(), ctrlMessage.GetWindowTextLength()); } else { bHandled = FALSE; } break; case VK_PRIOR: // page up ctrlClient.SendMessage(WM_VSCROLL, SB_PAGEUP); break; case VK_NEXT: // page down ctrlClient.SendMessage(WM_VSCROLL, SB_PAGEDOWN); break; case VK_HOME: if (!prevCommands.empty() && (GetKeyState(VK_CONTROL) & 0x8000) || (GetKeyState(VK_MENU) & 0x8000)) { curCommandPosition = 0; AutoArray<TCHAR> messageContents(ctrlMessage.GetWindowTextLength()+2); ctrlMessage.GetWindowText(messageContents, ctrlMessage.GetWindowTextLength()+1); currentCommand = tstring(messageContents); ctrlMessage.SetWindowText(prevCommands[curCommandPosition].c_str()); } else { bHandled = FALSE; } break; case VK_END: if ((GetKeyState(VK_CONTROL) & 0x8000) || (GetKeyState(VK_MENU) & 0x8000)) { curCommandPosition = prevCommands.size(); ctrlMessage.SetWindowText(currentCommand.c_str()); } else { bHandled = FALSE; } break; default: bHandled = FALSE; } } return 0; }
void Editor_menuEvent(int menuItem) { int highlightRowStep = getTrackData()->highlightRowStep; switch (menuItem) { case EDITOR_MENU_ENTER_CURRENT_V : case EDITOR_MENU_ROWS_UP : case EDITOR_MENU_ROWS_DOWN : case EDITOR_MENU_PREV_BOOKMARK : case EDITOR_MENU_NEXT_BOOKMARK : case EDITOR_MENU_PREV_KEY : case EDITOR_MENU_NEXT_KEY : case EDITOR_MENU_PLAY : { endEditing(); } } cancelEditing(); // If some internal control has focus we let it do its thing if (Emgui_hasKeyboardFocus()) { Editor_update(); return; } switch (menuItem) { // File case EDITOR_MENU_OPEN: onOpen(); break; case EDITOR_MENU_SAVE: onSave(); break; case EDITOR_MENU_SAVE_AS: onSaveAs(); break; case EDITOR_MENU_REMOTE_EXPORT : RemoteConnection_sendSaveCommand(); break; case EDITOR_MENU_RECENT_FILE_0: case EDITOR_MENU_RECENT_FILE_1: case EDITOR_MENU_RECENT_FILE_2: case EDITOR_MENU_RECENT_FILE_3: { Editor_loadRecentFile(menuItem - EDITOR_MENU_RECENT_FILE_0); break; } // Edit case EDITOR_MENU_UNDO : onUndo(); break; case EDITOR_MENU_REDO : onRedo(); break; case EDITOR_MENU_CANCEL_EDIT : onCancelEdit(); break; case EDITOR_MENU_DELETE_KEY : onDeleteKey(); break; case EDITOR_MENU_CUT : onCutAndCopy(true); break; case EDITOR_MENU_COPY : onCutAndCopy(false); break; case EDITOR_MENU_PASTE : onPaste(); break; case EDITOR_MENU_SELECT_TRACK : onSelectTrack(); break; case EDITOR_MENU_BIAS_P_001 : biasSelection(0.01f); break; case EDITOR_MENU_BIAS_P_01 : biasSelection(0.1f); break; case EDITOR_MENU_BIAS_P_1: biasSelection(1.0f); break; case EDITOR_MENU_BIAS_P_10: biasSelection(10.0f); break; case EDITOR_MENU_BIAS_P_100: biasSelection(100.0f); break; case EDITOR_MENU_BIAS_P_1000: biasSelection(1000.0f); break; case EDITOR_MENU_BIAS_N_001: biasSelection(-0.01f); break; case EDITOR_MENU_BIAS_N_01: biasSelection(-0.1f); break; case EDITOR_MENU_BIAS_N_1: biasSelection(-1.0f); break; case EDITOR_MENU_BIAS_N_10: biasSelection(-10.0f); break; case EDITOR_MENU_BIAS_N_100 : biasSelection(-100.0f); break; case EDITOR_MENU_BIAS_N_1000: biasSelection(-1000.0f); break; case EDITOR_MENU_INTERPOLATION : onInterpolation(); break; case EDITOR_MENU_ENTER_CURRENT_V : onEnterCurrentValue(); break; // View case EDITOR_MENU_PLAY : onPlay(); break; case EDITOR_MENU_ROWS_UP : onRowStep(-highlightRowStep , NO_SELECTION); break; case EDITOR_MENU_ROWS_DOWN : onRowStep(highlightRowStep , NO_SELECTION); break; case EDITOR_MENU_ROWS_2X_UP : onRowStep(-highlightRowStep * 2 , NO_SELECTION); break; case EDITOR_MENU_ROWS_2X_DOWN : onRowStep(highlightRowStep * 2 , NO_SELECTION); break; case EDITOR_MENU_PREV_BOOKMARK : onBookmarkDir(ARROW_UP, NO_SELECTION); break; case EDITOR_MENU_NEXT_BOOKMARK : onBookmarkDir(ARROW_DOWN, NO_SELECTION); break; case EDITOR_MENU_FIRST_TRACK : onTrackSide(ARROW_LEFT, true, NO_SELECTION); break; case EDITOR_MENU_LAST_TRACK : onTrackSide(ARROW_RIGHT, true, NO_SELECTION); break; case EDITOR_MENU_PREV_KEY : onPrevNextKey(true, NO_SELECTION); break; case EDITOR_MENU_NEXT_KEY : onPrevNextKey(false, NO_SELECTION); break; case EDITOR_MENU_FOLD_TRACK : onFoldTrack(true); break; case EDITOR_MENU_UNFOLD_TRACK : onFoldTrack(false); break; case EDITOR_MENU_FOLD_GROUP : onFoldGroup(true); break; case EDITOR_MENU_UNFOLD_GROUP : onFoldGroup(false); break; case EDITOR_MENU_TOGGLE_BOOKMARK : onToggleBookmark(); break; case EDITOR_MENU_CLEAR_BOOKMARKS : onClearBookmarks(); break; case EDITOR_MENU_TAB : onTab(); break; } Editor_update(); }