Merge pull request #2752 from Armada651/osx-beep

CFrame: Claim all keyboard events on OS X.
This commit is contained in:
Markus Wick 2015-07-20 13:55:05 +02:00
commit b5fe028e18
3 changed files with 15 additions and 2 deletions

View File

@ -1068,6 +1068,20 @@ bool TASInputHasFocus()
return false;
}
void CFrame::OnKeyDown(wxKeyEvent& event)
{
// On OS X, we claim all keyboard events while
// emulation is running to avoid wxWidgets sounding
// the system beep for unhandled key events when
// receiving pad/Wiimote keypresses which take an
// entirely different path through the HID subsystem.
#ifndef __APPLE__
// On other platforms, we leave the key event alone
// so it can be passed on to the windowing system.
event.Skip();
#endif
}
void CFrame::OnMouse(wxMouseEvent& event)
{
// next handlers are all for FreeLook, so we don't need to check them if disabled

View File

@ -320,8 +320,6 @@ private:
void OnToggleWindow(wxCommandEvent& event);
void OnKeyDown(wxKeyEvent& event); // Keyboard
void OnKeyUp(wxKeyEvent& event);
void OnMouse(wxMouseEvent& event); // Mouse
void OnFocusChange(wxFocusEvent& event);

View File

@ -1046,6 +1046,7 @@ void CFrame::StartGame(const std::string& filename)
m_RenderParent->SetFocus();
wxTheApp->Bind(wxEVT_KEY_DOWN, &CFrame::OnKeyDown, this);
wxTheApp->Bind(wxEVT_RIGHT_DOWN, &CFrame::OnMouse, this);
wxTheApp->Bind(wxEVT_RIGHT_UP, &CFrame::OnMouse, this);
wxTheApp->Bind(wxEVT_MIDDLE_DOWN, &CFrame::OnMouse, this);