Skip to content
Permalink
Browse files

Handle key{bindings,shortcuts} correctly on frame.

Some keybindings were not handled by the frame. That includes some
wxAcceleratorEntry keys. On Linux, if you set a key shortcut using a key
with no modifier ("U" for "Input > Configure"), pressing the key would
not lead to anything.

This is very likely related to wxGTK, although it is not possible to
confirm this at the moment.
  • Loading branch information
denisfa authored and rkitover committed Jun 11, 2019
1 parent cec1dbf commit 69b581f7e59a9b6a6bc54d80f650a36fc28ff633
Showing with 34 additions and 22 deletions.
  1. +26 −21 src/wx/wxvbam.cpp
  2. +8 −1 src/wx/wxvbam.h
@@ -816,6 +816,26 @@ void MainFrame::OnSize(wxSizeEvent& event)
update_opts();
}

int MainFrame::FilterEvent(wxEvent& event)
{
if (!IsPaused() && event.GetEventType() == wxEVT_KEY_DOWN)
{
wxKeyEvent& ke = (wxKeyEvent&)event;
int keyCode = ke.GetKeyCode();
int keyMod = ke.GetModifiers();
wxAcceleratorEntry_v accels = wxGetApp().GetAccels();
for (size_t i = 0; i < accels.size(); ++i)
if (keyCode == accels[i].GetKeyCode() && keyMod == accels[i].GetFlags())
{
wxCommandEvent evh(wxEVT_COMMAND_MENU_SELECTED, accels[i].GetCommand());
evh.SetEventObject(this);
GetEventHandler()->ProcessEvent(evh);
return true;
}
}
return -1;
}

wxString MainFrame::GetGamePath(wxString path)
{
wxString game_path = path;
@@ -1217,24 +1237,9 @@ void MainFrame::IdentifyRom()
// a few keys (e.g. only ctrl-x works for exit, but not esc & ctrl-q;
// ctrl-w does not work for close). It's possible another entity is
// grabbing those keys, but I can't track it down.
// FIXME: move this to MainFrame
//int wxvbamApp::FilterEvent(wxEvent& event)
//{
// //if(frame && frame->IsPaused(true))
// return -1;
//
// if (event.GetEventType() == wxEVT_KEY_DOWN) {
// wxKeyEvent& ke = (wxKeyEvent&)event;
//
// for (int i = 0; i < accels.size(); i++) {
// if (accels[i].GetKeyCode() == ke.GetKeyCode() && accels[i].GetFlags() == ke.GetModifiers()) {
// wxCommandEvent ev(wxEVT_COMMAND_MENU_SELECTED, accels[i].GetCommand());
// ev.SetEventObject(this);
// frame->GetEventHandler()->ProcessEvent(ev);
// return 1;
// }
// }
// }
//
// return -1;
//}
int wxvbamApp::FilterEvent(wxEvent& event)
{
if (frame)
return frame->FilterEvent(event);
return wxApp::FilterEvent(event);
}
@@ -108,9 +108,14 @@ class wxvbamApp : public wxApp {
};
#endif
// without this, global accels don't always work
//int FilterEvent(wxEvent& event);
int FilterEvent(wxEvent&);
wxAcceleratorEntry_v accels;

wxAcceleratorEntry_v GetAccels()
{
return accels;
}

// the main configuration
wxFileConfig* cfg;
// vba-over.ini
@@ -230,6 +235,8 @@ class MainFrame : public wxFrame {

void SetJoystick();

int FilterEvent(wxEvent& event);

GameArea* GetPanel()
{
return panel;

0 comments on commit 69b581f

Please sign in to comment.
You can’t perform that action at this time.