void DialogStyleManager::OnKeyDown(wxKeyEvent &event) { wxWindow *focus = wxWindow::FindFocus(); switch(event.GetKeyCode()) { case WXK_DELETE : if (focus == StorageList) OnStorageDelete(); else if (focus == CurrentList) OnCurrentDelete(); break; case 'C' : case 'c' : if (event.CmdDown()) { if (focus == StorageList) CopyToClipboard(StorageList, Store); else if (focus == CurrentList) CopyToClipboard(CurrentList, styleMap); } break; case 'V' : case 'v' : if (event.CmdDown()) { if (focus == StorageList) PasteToStorage(); else if (focus == CurrentList) PasteToCurrent(); } break; default: event.Skip(); break; } }
void MainSequencer::OnChar(wxKeyEvent& event) { wxChar uc = event.GetUnicodeKey(); KeyBinding *binding = keyBindings.Find(uc); if (binding != NULL) { event.StopPropagation(); switch (binding->GetType()) { case TIMING_ADD: InsertTimingMarkFromRange(); break; case TIMING_SPLIT: SplitTimingMark(); break; case KEY_ZOOM_IN: PanelTimeLine->ZoomIn(); break; case KEY_ZOOM_OUT: PanelTimeLine->ZoomOut(); break; case RANDOM_EFFECT: PanelEffectGrid->Paste("Random\t\t\n"); break; case EFFECT_STRING: PanelEffectGrid->Paste(binding->GetEffectName() + "\t" + binding->GetEffectString() + "\t\n"); break; } } //printf("OnChar %d %c\n", uc, uc); switch(uc) { case 'c': case 'C': case WXK_CONTROL_C: if (event.CmdDown() || event.ControlDown()) { CopySelectedEffects(); PanelEffectGrid->SetCanPaste(); event.StopPropagation(); } break; case 'x': case 'X': case WXK_CONTROL_X: if (event.CmdDown() || event.ControlDown()) { CopySelectedEffects(); PanelEffectGrid->DeleteSelectedEffects(); event.StopPropagation(); } break; case 'v': case 'V': case WXK_CONTROL_V: if (event.CmdDown() || event.ControlDown()) { Paste(); event.StopPropagation(); } break; } }
void AssistPanel::OnCharHook(wxKeyEvent& event) { if( mEffect != NULL ) { if( mEffect->GetEffectIndex() == EffectManager::eff_PICTURES ) { wxChar uc = event.GetUnicodeKey(); switch(uc) { case 'c': case 'C': case WXK_CONTROL_C: if (event.CmdDown() || event.ControlDown()) { if( mGridCanvas != nullptr ) { mGridCanvas->Copy(); } event.StopPropagation(); } break; case 'v': case 'V': case WXK_CONTROL_V: if (event.CmdDown() || event.ControlDown()) { if( mGridCanvas != nullptr ) { mGridCanvas->Paste(); } event.StopPropagation(); } break; #ifdef __WXMSW__ case WXK_INSERT: case WXK_NUMPAD_INSERT: if (event.ControlDown()) // Copy { if (mGridCanvas != nullptr) { mGridCanvas->Copy(); } event.StopPropagation(); } else if (GetKeyState(VK_LSHIFT) || GetKeyState(VK_RSHIFT)) // Paste { if (mGridCanvas != nullptr) { mGridCanvas->Paste(); } event.StopPropagation(); } break; #endif default: event.Skip(); break; } } } }
void NotebookNavigationDlg::OnKeyDown(wxKeyEvent& event) { if((event.GetUnicodeKey() == WXK_TAB) && ( #ifdef __WXOSX__ event.AltDown() #else event.CmdDown() #endif && event.ShiftDown())) { // Navigate Up wxDataViewItem item = m_dvListCtrl->GetSelection(); if(item.IsOk()) { int row = m_dvListCtrl->ItemToRow(item); if(row > 0) { --row; item = m_dvListCtrl->RowToItem(row); m_dvListCtrl->Select(item); m_dvListCtrl->EnsureVisible(item); } else { // Select the last item row = m_dvListCtrl->GetItemCount() - 1; item = m_dvListCtrl->RowToItem(row); m_dvListCtrl->Select(item); m_dvListCtrl->EnsureVisible(item); } } } else if((event.GetUnicodeKey() == WXK_TAB) && #ifdef __WXOSX__ event.AltDown() #else event.CmdDown() #endif ) { // Navigate Down wxDataViewItem item = m_dvListCtrl->GetSelection(); if(item.IsOk()) { int row = m_dvListCtrl->ItemToRow(item); if(row < (m_dvListCtrl->GetItemCount() - 1)) { ++row; item = m_dvListCtrl->RowToItem(row); m_dvListCtrl->Select(item); m_dvListCtrl->EnsureVisible(item); } else { // Select the last item item = m_dvListCtrl->RowToItem(0); m_dvListCtrl->Select(item); m_dvListCtrl->EnsureVisible(item); } } } else { event.Skip(); } }
PlatformKeyboardEvent::PlatformKeyboardEvent(wxKeyEvent& event) { if (event.GetEventType() == wxEVT_KEY_UP) m_type = KeyUp; else if (event.GetEventType() == wxEVT_KEY_DOWN) m_type = KeyDown; else if (event.GetEventType() == wxEVT_CHAR) m_type = Char; else ASSERT_NOT_REACHED(); if (m_type != Char) m_keyIdentifier = keyIdentifierForWxKeyCode(event.GetKeyCode()); else { //ENTER is an editing command processed as a char (only Enter and Tab are) //unfortunately the unicode key for numpad_enter (370) is NOT what we want here (13) //The unicode values for normal enter and tab are the same as the ASCII values, thus ok //Note that I think this a wx bug, as the Character Code is actually 13 when //numpad_enter is a CHAR event. if (event.GetKeyCode() == 13 && event.GetUnicodeKey() == wxChar(370)) m_text = "\r"; else m_text = wxString(event.GetUnicodeKey()); m_unmodifiedText = m_text; } m_autoRepeat = false; // FIXME: not correct. m_windowsVirtualKeyCode = windowsKeyCodeForKeyEvent(event.GetKeyCode()); m_nativeVirtualKeyCode = event.GetKeyCode(); m_isKeypad = (event.GetKeyCode() >= WXK_NUMPAD_SPACE) && (event.GetKeyCode() <= WXK_NUMPAD_DIVIDE); m_shiftKey = event.ShiftDown(); m_ctrlKey = event.CmdDown(); m_altKey = event.AltDown(); m_metaKey = event.MetaDown(); }
void IntegerDialog::OnSpinCtrlChar(wxKeyEvent& event) { int key = event.GetKeyCode(); if (event.CmdDown()) { // allow handling of cmd-x/v/etc event.Skip(); } else if ( key == WXK_TAB ) { wxSpinCtrl* sc = (wxSpinCtrl*) FindWindowById(ID_SPIN_CTRL); if ( sc ) { sc->SetFocus(); sc->SetSelection(-1,-1); } } else if ( key >= ' ' && key <= '~' ) { if ( (key >= '0' && key <= '9') || key == '+' || key == '-' ) { // allow digits and + or - event.Skip(); } else { // disallow any other displayable ascii char Beep(); } } else { event.Skip(); } }
KeyAcceleratorCode::KeyAcceleratorCode( const wxKeyEvent& evt ) { val32 = 0; keycode = evt.GetKeyCode(); if( evt.AltDown() ) Alt(); if( evt.CmdDown() ) Cmd(); if( evt.ShiftDown() ) Shift(); }
void AssistPanel::OnCharHook(wxKeyEvent& event) { if( mEffect != NULL ) { if( mEffect->GetEffectIndex() == EffectManager::eff_PICTURES ) { wxChar uc = event.GetUnicodeKey(); switch(uc) { case 'c': case 'C': case WXK_CONTROL_C: if (event.CmdDown() || event.ControlDown()) { if( mGridCanvas != nullptr ) { mGridCanvas->Copy(); } event.StopPropagation(); } break; case 'v': case 'V': case WXK_CONTROL_V: if (event.CmdDown() || event.ControlDown()) { if( mGridCanvas != nullptr ) { mGridCanvas->Paste(); } event.StopPropagation(); } break; default: event.Skip(); break; } } } }
PlatformKeyboardEvent::PlatformKeyboardEvent(wxKeyEvent& event) { m_text = wxString(event.GetUnicodeKey()); m_unmodifiedText = m_text; m_keyIdentifier = keyIdentifierForWxKeyCode(event.GetKeyCode()); m_isKeyUp = event.GetEventType() == wxEVT_KEY_UP; m_autoRepeat = false; // FIXME: not correct. m_WindowsKeyCode = windowsKeyCodeForKeyEvent(event.GetKeyCode()); m_isKeypad = (event.GetKeyCode() >= WXK_NUMPAD_SPACE) && (event.GetKeyCode() <= WXK_NUMPAD_DIVIDE); m_shiftKey = event.ShiftDown(); m_ctrlKey = event.CmdDown(); m_altKey = event.AltDown(); m_metaKey = event.MetaDown(); }
void TimeEdit::OnKeyDown(wxKeyEvent &event) { int kc = event.GetKeyCode(); // Needs to be done here to trump user-defined hotkeys int key = event.GetUnicodeKey(); if (event.CmdDown()) { if (key == 'C' || key == 'X') CopyTime(); else if (key == 'V') PasteTime(); else event.Skip(); return; } // Shift-Insert would paste the stuff anyway // but no one updates the private "time" variable. if (event.ShiftDown() && kc == WXK_INSERT) { PasteTime(); return; } if (byFrame || insert) { event.Skip(); return; } // Overwrite mode stuff // On OS X backspace is reported as delete #ifdef __APPLE__ if (kc == WXK_DELETE) kc = WXK_BACK; #endif // Back just moves cursor back one without deleting if (kc == WXK_BACK) { long start = GetInsertionPoint(); if (start > 0) SetInsertionPoint(start - 1); } // Delete just does nothing else if (kc != WXK_DELETE) event.Skip(); }
void wxWebView::OnKeyEvents(wxKeyEvent& event) { WebCore::Frame* frame = 0; if (m_mainFrame) frame = m_mainFrame->GetFrame(); if (frame && frame->view()) { // WebCore doesn't handle these events itself, so we need to do // it and not send the event down or else CTRL+C will erase the text // and replace it with c. if (event.CmdDown() && event.GetEventType() == wxEVT_KEY_UP) { if (event.GetKeyCode() == static_cast<int>('C')) Copy(); else if (event.GetKeyCode() == static_cast<int>('X')) Cut(); else if (event.GetKeyCode() == static_cast<int>('V')) Paste(); else if (event.GetKeyCode() == static_cast<int>('Z')) { if (event.ShiftDown()) { if (m_mainFrame->CanRedo()) m_mainFrame->Redo(); } else { if (m_mainFrame->CanUndo()) m_mainFrame->Undo(); } } } else { WebCore::PlatformKeyboardEvent wkEvent(event); if (wkEvent.type() == WebCore::PlatformKeyboardEvent::Char && wkEvent.altKey()) frame->eventHandler()->handleAccessKey(wkEvent); else frame->eventHandler()->keyEvent(wkEvent); } } // make sure we get the character event. if (event.GetEventType() != wxEVT_CHAR) event.Skip(); }
void CMuleListCtrl::OnChar(wxKeyEvent& evt) { int key = evt.GetKeyCode(); if (key == 0) { // We prefer GetKeyCode() to GetUnicodeKey(), in order to work // around a bug in the GetUnicodeKey(), that causes values to // be returned untranslated. This means for instance, that if // shift and '1' is pressed, the result is '1' rather than '!' // (as it should be on my keyboard). This has been reported: // http://sourceforge.net/tracker/index.php?func=detail&aid=1864810&group_id=9863&atid=109863 key = evt.GetUnicodeKey(); } else if (key >= WXK_START) { // wxKeycodes are ignored, as they signify events such as the 'home' // button. Unicoded chars are not checked as there is an overlap valid // chars and the wx keycodes. evt.Skip(); return; } // We wish to avoid handling shortcuts, with the exception of 'select-all'. if (evt.AltDown() || evt.ControlDown() || evt.MetaDown()) { if (evt.CmdDown() && (evt.GetKeyCode() == 0x01)) { // Ctrl+a (Command+a on Mac) was pressed, select all items for (int i = 0; i < GetItemCount(); ++i) { SetItemState(i, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED); } } evt.Skip(); return; } else if (m_tts_time + 1500u < GetTickCount()) { m_tts_text.Clear(); } m_tts_time = GetTickCount(); m_tts_text.Append(wxTolower(key)); // May happen if the subclass does not forward deletion events. // Or rather when single-char-repeated (see below) wraps around, so don't assert. if (m_tts_item >= GetItemCount()) { m_tts_item = -1; } unsigned next = (m_tts_item == -1) ? 0 : m_tts_item; for (unsigned i = 0, count = GetItemCount(); i < count; ++i) { wxString text = GetTTSText((next + i) % count).MakeLower(); if (text.StartsWith(m_tts_text)) { ClearSelection(); m_tts_item = (next + i) % count; SetItemState(m_tts_item, wxLIST_STATE_FOCUSED | wxLIST_STATE_SELECTED, wxLIST_STATE_FOCUSED | wxLIST_STATE_SELECTED); EnsureVisible(m_tts_item); return; } } if (m_tts_item != -1) { // Crop the string so that it matches the old item (avoid typos). wxString text = GetTTSText(m_tts_item).MakeLower(); // If the last key didn't result in a hit, then we skip the event. if (!text.StartsWith(m_tts_text)) { if ((m_tts_text.Length() == 2) && (m_tts_text[0] == m_tts_text[1])) { // Special case, single-char, repeated. This allows toggeling // between items starting with a specific letter. m_tts_text.Clear(); // Increment, so the next will be selected (or wrap around). m_tts_item++; OnChar(evt); } else { m_tts_text.RemoveLast(); evt.Skip(true); } } } else { evt.Skip(true); } }
void TimeEdit::OnKeyDown(wxKeyEvent &event) { int key = event.GetKeyCode(); if (event.CmdDown()) { if (key == 'C' || key == 'X') CopyTime(); else if (key == 'V') PasteTime(); else event.Skip(); return; } // Shift-Insert would paste the stuff anyway // but no one updates the private "time" variable. if (event.ShiftDown() && key == WXK_INSERT) { PasteTime(); return; } // Translate numpad presses to normal numbers if (key >= WXK_NUMPAD0 && key <= WXK_NUMPAD9) key += '0' - WXK_NUMPAD0; // If overwriting is disabled, we're in frame mode, or it's a key we // don't care about just let the standard processing happen event.Skip(); if (byFrame) return; if (insert) return; if ((key < '0' || key > '9') && key != WXK_BACK && key != WXK_DELETE && key != ';' && key != '.') return; event.Skip(false); long start = GetInsertionPoint(); wxString text = GetValue(); // Delete does nothing if (key == WXK_DELETE) return; // Back just moves cursor back one without deleting if (key == WXK_BACK) { if (start > 0) SetInsertionPoint(start - 1); return; } // Cursor is at the end so do nothing if (start >= (long)text.size()) return; // If the cursor is at punctuation, move it forward to the next digit if (text[start] == ':' || text[start] == '.') ++start; // : and . hop over punctuation but never insert anything if (key == ';' || key == '.') { SetInsertionPoint(start); return; } // Overwrite the digit time = text.Left(start) + (char)key + text.Mid(start + 1); SetValue(time.GetASSFormated()); SetInsertionPoint(start + 1); }
void P3DCanvas3D::OnChar (wxKeyEvent &event) { bool CameraChanged; int KeyCode; CameraChanged = true; KeyCode = event.GetKeyCode(); if (P3DApp::GetApp()->GetCameraControlPrefs()->EmulateNumpad) { if (event.CmdDown() && KeyCode >= '0' && KeyCode <= '9') { KeyCode = NumPadEmulationKeyMap[KeyCode - '0']; } } if (KeyCode == WXK_NUMPAD1 || KeyCode == WXK_NUMPAD_END) { P3DQuaternionf Rotation; camera.SetCenter(0.0f,0.0f,0.0f); if (event.ShiftDown()) { Rotation.FromAxisAndAngle(0.0f,1.0f,0.0f,P3DMATH_PI); camera.SetDirection(Rotation.q[0], Rotation.q[1], Rotation.q[2], Rotation.q[3]); } else { camera.SetDirection(0.0f,0.0f,0.0f,1.0f); } } else if (KeyCode == WXK_NUMPAD7 || KeyCode == WXK_NUMPAD_HOME) { P3DQuaternionf Rotation; if (event.ShiftDown()) { Rotation.FromAxisAndAngle(-1.0f,0.0f,0.0f,P3DMATH_PI / 2); } else { Rotation.FromAxisAndAngle(1.0f,0.0f,0.0f,P3DMATH_PI / 2); } camera.SetCenter(0.0f,0.0f,0.0f); camera.SetDirection(Rotation.q[0], Rotation.q[1], Rotation.q[2], Rotation.q[3]); } else if (KeyCode == WXK_NUMPAD3 || KeyCode == WXK_NUMPAD_PAGEDOWN) { P3DQuaternionf Rotation; if (event.ShiftDown()) { Rotation.FromAxisAndAngle(0.0f,1.0f,0.0f,P3DMATH_PI / 2); } else { Rotation.FromAxisAndAngle(0.0f,-1.0f,0.0f,P3DMATH_PI / 2); } camera.SetCenter(0.0f,0.0f,0.0f); camera.SetDirection(Rotation.q[0], Rotation.q[1], Rotation.q[2], Rotation.q[3]); } else if (KeyCode == WXK_NUMPAD4 || KeyCode == WXK_NUMPAD_LEFT) { camera.RotateWS(P3DMATH_PI / 12.0f,0.0f,1.0f,0.0f); } else if (KeyCode == WXK_NUMPAD6 || KeyCode == WXK_NUMPAD_RIGHT) { camera.RotateWS(P3DMATH_PI / 12.0f,0.0f,-1.0f,0.0f); } else if (KeyCode == WXK_NUMPAD8 || KeyCode == WXK_NUMPAD_UP) { camera.RotateCS(P3DMATH_PI / 12.0f,1.0f,0.0f,0.0f); } else if (KeyCode == WXK_NUMPAD2 || KeyCode == WXK_NUMPAD_DOWN) { camera.RotateCS(P3DMATH_PI / 12.0f,-1.0f,0.0f,0.0f); } else if (KeyCode == WXK_NUMPAD_ADD || KeyCode == '+' || KeyCode == '=') { ZoomFactor *= 0.75f; } else if (KeyCode == WXK_NUMPAD_SUBTRACT || KeyCode == '-') { ZoomFactor *= 4.0f / 3.0f; } else if (KeyCode == WXK_NUMPAD5 || KeyCode == WXK_NUMPAD_BEGIN) { OrthoCamera = !OrthoCamera; } else { CameraChanged = false; event.Skip(); } if (CameraChanged) { P3DApp::GetApp()->InvalidateCamera(); Refresh(); } }
void CComposeBarEditBox::OnKeyUp(wxKeyEvent& event) { /* turned out to be a pseudo key binding in accelerator keys code, in CMainFrame creator #if defined(KEY_2_KLUGE) && !defined(__GNUG__) && !defined(__APPLE__) // kluge to workaround the problem of a '2' (event.m_keycode = 50) keypress being // interpretted as a F10 function keypress (event.m_keyCode == 121) if (event.m_keyCode == 50) { CMainFrame* pFrame = gpApp->GetMainFrame(); if (pFrame->m_pComposeBar != NULL) { wxTextCtrl* pEditBox = pFrame->m_pComposeBarEditBox; long from; long to; pEditBox->GetSelection(&from,&to); wxString a2key = _T('2'); pEditBox->Replace(from,to,a2key); return; } } #endif */ // BEW 8Jul14 intercept the CTRL+SHIFT+<spacebar> combination to enter a ZWSP // (zero width space) into the composebar's editbox; replacing a selection if // there is one defined if (event.GetKeyCode() == WXK_SPACE) { if (!event.AltDown() && event.CmdDown() && event.ShiftDown()) { OnCtrlShiftSpacebar(this); // see helpers.h & .cpp return; // don't call skip - we don't want the end-of-line character entered // into the edit box } } if (gpApp->m_bFreeTranslationMode) { // GDLC 2010-03-27 pView no longer used // CAdapt_ItView* pView = gpApp->GetView(); // wxASSERT(pView != NULL); CFreeTrans* pFreeTrans = gpApp->GetFreeTrans(); wxASSERT(pFreeTrans != NULL); wxCommandEvent bevent; // the following block is a work-around to get the ALT+key short-cut keys to work // for the buttons on the composebar if (event.AltDown()) { int key = event.GetKeyCode(); if (wxChar(key) == _T('S')) { pFreeTrans->OnShortenButton(bevent); } else if (wxChar(key) == _T('L')) { pFreeTrans->OnLengthenButton(bevent); } else if (wxChar(key) == _T('R')) { pFreeTrans->OnRemoveFreeTranslationButton(bevent); } else if (wxChar(key) == _T('P')) { pFreeTrans->OnPrevButton(bevent); } else if (wxChar(key) == _T('N')) { pFreeTrans->OnNextButton(bevent); } else if (wxChar(key) == _T('V')) { pFreeTrans->OnAdvanceButton(bevent); } else if (wxChar(key) == _T('U')) { pFreeTrans->OnRadioDefineByPunctuation(bevent); } else if (wxChar(key) == _T('E')) { pFreeTrans->OnRadioDefineByVerse(bevent); } } } // do not call Skip here to avoid beep in base class' control handlers // and we don't want any base class behaviours here either //event.Skip(); }
void BaseGrid::OnKeyDown(wxKeyEvent &event) { int w,h; GetClientSize(&w,&h); int key = event.GetKeyCode(); bool ctrl = event.CmdDown(); bool alt = event.AltDown(); bool shift = event.ShiftDown(); int dir = 0; int step = 1; if (key == WXK_UP) dir = -1; else if (key == WXK_DOWN) dir = 1; else if (key == WXK_PAGEUP) { dir = -1; step = h / lineHeight - 2; } else if (key == WXK_PAGEDOWN) { dir = 1; step = h / lineHeight - 2; } else if (key == WXK_HOME) { dir = -1; step = GetRows(); } else if (key == WXK_END) { dir = 1; step = GetRows(); } if (!dir) { event.Skip(); return; } int old_extend = extendRow; int next = mid(0, GetDialogueIndex(active_line) + dir * step, GetRows() - 1); SetActiveLine(GetDialogue(next)); // Move selection if (!ctrl && !shift && !alt) { SelectRow(next); return; } // Move active only if (alt && !shift && !ctrl) { Refresh(false); return; } // Shift-selection if (shift && !ctrl && !alt) { extendRow = old_extend; // Set range int begin = next; int end = extendRow; if (end < begin) std::swap(begin, end); // Select range Selection newsel; for (int i = begin; i <= end; i++) newsel.insert(GetDialogue(i)); SetSelectedSet(newsel); MakeCellVisible(next, 0, false); return; } }