///Call this when a key event is received. ///If it matches a command, it will call the appropriate ///CommandManagerListener function. If you pass any flags, ///the command won't be executed unless the flags are compatible ///with the command's flags. bool CommandManager::HandleKey(wxKeyEvent &evt, wxUint32 flags, wxUint32 mask) { wxString keyStr = KeyEventToKeyString(evt); CommandListEntry *entry = mCommandKeyHash[keyStr]; if (evt.GetEventType() == wxEVT_KEY_DOWN) { return HandleCommandEntry( entry, flags, mask, &evt ); } if (entry && entry->wantevent) { return HandleCommandEntry( entry, flags, mask, &evt ); } return false; }
void KeyConfigPrefs::OnFilterKeyDown(wxKeyEvent & e) { wxTextCtrl *t = (wxTextCtrl *)e.GetEventObject(); int keycode = e.GetKeyCode(); // Make sure we can navigate away from the hotkey textctrl. // On Linux and OSX, it an get stuck, but it doesn't hurt // to do it for Windows as well. if (keycode == WXK_TAB) { wxNavigationKeyEvent nevent; nevent.SetWindowChange(e.ControlDown()); nevent.SetDirection(!e.ShiftDown()); nevent.SetEventObject(t); nevent.SetCurrentFocus(t); t->GetParent()->GetEventHandler()->ProcessEvent(nevent); return; } if (mViewType == ViewByKey) { wxString key = KeyStringDisplay(KeyEventToKeyString(e)); t->SetValue(key); if (key != wxEmptyString) { mView->SetFilter(t->GetValue()); } } else { if (keycode == WXK_RETURN) { mFilterPending = false; mView->SetFilter(t->GetValue()); } else { mFilterPending = true; mFilterTimer.Start(500, wxTIMER_ONE_SHOT); e.Skip(); } } }
void KeyConfigPrefs::OnHotkeyKeyDown(wxKeyEvent & e) { wxTextCtrl *t = (wxTextCtrl *)e.GetEventObject(); // Make sure we can navigate away from the hotkey textctrl. // On Linux and OSX, it can get stuck, but it doesn't hurt // to do it for Windows as well. // // Mac note: Don't waste time trying to figure out why the // focus goes back to the prefs tree. Unless Voiceover is // active, buttons on the Mac do not accept focus and all the // controls between this one and the tree control are buttons. if (e.GetKeyCode() == WXK_TAB) { NavigateIn(e.ShiftDown() ? wxNavigationKeyEvent::IsBackward : wxNavigationKeyEvent::IsForward); return; } t->SetValue(KeyStringDisplay(KeyEventToKeyString(e))); }
//BG: It works on Windows, but we need to trap WM_CHAR //DM: On Linux, now it works except for Ctrl+3...Ctrl+8 (April/2003) void SysKeyTextCtrl::OnKey(wxKeyEvent& event) { SetValue(KeyEventToKeyString(event)); }
///Call this when a key event is received. ///If it matches a command, it will call the appropriate ///CommandManagerListener function. If you pass any flags, ///the command won't be executed unless the flags are compatible ///with the command's flags. bool CommandManager::HandleKey(wxKeyEvent &evt, wxUint32 flags, wxUint32 mask) { wxString keyStr = KeyEventToKeyString(evt); CommandListEntry *entry = mCommandKeyHash[keyStr]; return HandleCommandEntry( entry, flags, mask ); }