More fixes to hotkeys, consequently use Cmd instead of Ctrl on Mac, changed some default hotkeys on Mac to avoid clashes with system hotkeys and better follow Apple HIG.

Originally committed to SVN as r1579.
This commit is contained in:
Niels Martin Hansen 2007-09-22 15:16:48 +00:00
parent 808f56d294
commit acc2d3753f
7 changed files with 50 additions and 3 deletions

View File

@ -2000,7 +2000,11 @@ void AudioDisplay::OnUpdateTimer(wxTimerEvent &event) {
// Key down
void AudioDisplay::OnKeyDown(wxKeyEvent &event) {
int key = event.GetKeyCode();
#ifdef __APPLE__
Hotkeys.SetPressed(key,event.m_metaDown,event.m_altDown,event.m_shiftDown);
#else
Hotkeys.SetPressed(key,event.m_controlDown,event.m_altDown,event.m_shiftDown);
#endif
// Accept
if (Hotkeys.IsPressed(_T("Audio Commit"))) {

View File

@ -1048,7 +1048,11 @@ void CaptureKey::OnKeyDown(wxKeyEvent &event) {
parent->key->keycode = keycode;
int mod = 0;
if (event.m_altDown) mod |= wxACCEL_ALT;
#ifdef __APPLE__
if (event.m_metaDown) mod |= wxACCEL_CTRL;
#else
if (event.m_controlDown) mod |= wxACCEL_CTRL;
#endif
if (event.m_shiftDown) mod |= wxACCEL_SHIFT;
parent->key->flags = mod;
parent->EndModal(0);

View File

@ -337,10 +337,18 @@ END_EVENT_TABLE()
// Key pressed
void StyleEditBox::OnKeyDown(wxKeyEvent &event) {
//int keycode = event.GetKeyCode();
#ifdef __APPLE__
Hotkeys.SetPressed(event.GetKeyCode(),event.m_metaDown,event.m_altDown,event.m_shiftDown);
#else
Hotkeys.SetPressed(event.GetKeyCode(),event.m_controlDown,event.m_altDown,event.m_shiftDown);
#endif
// Backspace
#ifdef __APPLE__
if (event.GetKeyCode() == WXK_BACK && !event.m_metaDown && !event.m_altDown && !event.m_shiftDown) {
#else
if (event.GetKeyCode() == WXK_BACK && !event.m_controlDown && !event.m_altDown && !event.m_shiftDown) {
#endif
long from,to;
GetSelection(&from,&to);
if (from > 0) SetSelection(from-1,to);

View File

@ -272,7 +272,11 @@ void DialogTranslationEvent::OnTransBoxKey(wxKeyEvent &event) { control->OnTrans
/////////////////////
// Key pressed event
void DialogTranslation::OnTransBoxKey(wxKeyEvent &event) {
#ifdef __APPLE__
Hotkeys.SetPressed(event.GetKeyCode(),event.m_metaDown,event.m_altDown,event.m_shiftDown);
#else
Hotkeys.SetPressed(event.GetKeyCode(),event.m_controlDown,event.m_altDown,event.m_shiftDown);
#endif
// Previous
if (Hotkeys.IsPressed(_T("Translation Assistant Prev"))) {

View File

@ -157,6 +157,7 @@ wxString HotkeyType::GetKeyName(int keycode) {
// Fill map
void HotkeyType::FillMap() {
if (keyName.empty()) {
keyName[WXK_BACK] = _T("Backspace");
keyName[WXK_SPACE] = _T("Space");
keyName[WXK_RETURN] = _T("Enter");
keyName[WXK_TAB] = _T("Tab");
@ -316,24 +317,43 @@ void HotkeyManager::LoadDefaults() {
SetHotkey(_("New subtitles"),_T("Ctrl-N"));
SetHotkey(_("Open subtitles"),_T("Ctrl-O"));
SetHotkey(_("Save subtitles"),_T("Ctrl-S"));
#ifdef __APPLE__
SetHotkey(_("Exit"),_T("Ctrl-Q"));
SetHotkey(_("Help"),_T("Ctrl-?"));
SetHotkey(_("Options"),_T("Ctrl-,"));
#else
SetHotkey(_("Exit"),_T("Alt-F4"));
SetHotkey(_("Help"),_T("F1"));
SetHotkey(_("Options"),_T("Alt-O"));
#endif
SetHotkey(_("Edit Box Commit"),_T("Ctrl-Enter"));
SetHotkey(_("Undo"),_T("Ctrl-Z"));
#ifdef __APPLE__
SetHotkey(_("Redo"),_T("Ctrl-Shift-Z"));
#else
SetHotkey(_("Redo"),_T("Ctrl-Y"));
#endif
SetHotkey(_("Shift Times"),_T("Ctrl-I"));
SetHotkey(_("Find"),_T("Ctrl-F"));
#ifdef __APPLE__
SetHotkey(_("Find Next"),_T("Ctrl-G"));
SetHotkey(_("Replace"),_T("Ctrl-Shift-F")); // non-standard?
#else
SetHotkey(_("Find Next"),_T("F3"));
SetHotkey(_("Replace"),_T("Ctrl-H"));
#endif
SetHotkey(_("Select Lines"),_T(""));
SetHotkey(_("Copy"),_T("Ctrl-C"));
SetHotkey(_("Cut"),_T("Ctrl-X"));
SetHotkey(_("Paste"),_T("Ctrl-V"));
SetHotkey(_("Paste Over"),_T("Ctrl-Shift-V"));
#ifdef __APPLE__
SetHotkey(_("Video Jump"),_T("Ctrl-J"));
#else
SetHotkey(_("Video Jump"),_T("Ctrl-G"));
#endif
SetHotkey(_("Jump Video to Start"),_T("Ctrl-1"));
SetHotkey(_("Jump Video to End"),_T("Ctrl-2"));
SetHotkey(_("Set Start to Video"),_T("Ctrl-3"));
@ -356,7 +376,11 @@ void HotkeyManager::LoadDefaults() {
SetHotkey(_("Grid move row down"),_T("Alt-Down"));
SetHotkey(_("Grid move row up"),_T("Alt-Up"));
#ifdef __APPLE__
SetHotkey(_("Grid delete rows"),_T("Ctrl-Backspace"));
#else
SetHotkey(_("Grid delete rows"),_T("Ctrl-Delete"));
#endif
SetHotkey(_("Grid duplicate rows"),_T(""));
SetHotkey(_("Grid duplicate and shift one frame"),_T("Ctrl-D"));

View File

@ -1296,11 +1296,10 @@ void SubsEditBox::OnButtonStrikeout(wxCommandEvent &event) {
//////////
// Commit
void SubsEditBox::OnButtonCommit(wxCommandEvent &event) {
Commit(wxGetMouseState().
#ifdef __APPLE__
CmdDown());
Commit(wxGetMouseState().CmdDown());
#else
ControlDown());
Commit(wxGetMouseState().ControlDown());
#endif
}

View File

@ -226,7 +226,11 @@ void SubtitlesGrid::OnShowColMenu(wxCommandEvent &event) {
// Process keyboard events
void SubtitlesGrid::OnKeyDown(wxKeyEvent &event) {
// Get key
#ifdef __APPLE__
Hotkeys.SetPressed(event.GetKeyCode(),event.m_metaDown,event.m_altDown,event.m_shiftDown);
#else
Hotkeys.SetPressed(event.GetKeyCode(),event.m_controlDown,event.m_altDown,event.m_shiftDown);
#endif
// Get selection
bool continuous = false;