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.
This commit is contained in:
parent
cec1dbfd36
commit
69b581f7e5
|
@ -816,6 +816,26 @@ void MainFrame::OnSize(wxSizeEvent& event)
|
||||||
update_opts();
|
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 MainFrame::GetGamePath(wxString path)
|
||||||
{
|
{
|
||||||
wxString game_path = 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;
|
// 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
|
// ctrl-w does not work for close). It's possible another entity is
|
||||||
// grabbing those keys, but I can't track it down.
|
// grabbing those keys, but I can't track it down.
|
||||||
// FIXME: move this to MainFrame
|
int wxvbamApp::FilterEvent(wxEvent& event)
|
||||||
//int wxvbamApp::FilterEvent(wxEvent& event)
|
{
|
||||||
//{
|
if (frame)
|
||||||
// //if(frame && frame->IsPaused(true))
|
return frame->FilterEvent(event);
|
||||||
// return -1;
|
return wxApp::FilterEvent(event);
|
||||||
//
|
}
|
||||||
// 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;
|
|
||||||
//}
|
|
||||||
|
|
|
@ -108,9 +108,14 @@ public:
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
// without this, global accels don't always work
|
// without this, global accels don't always work
|
||||||
//int FilterEvent(wxEvent& event);
|
int FilterEvent(wxEvent&);
|
||||||
wxAcceleratorEntry_v accels;
|
wxAcceleratorEntry_v accels;
|
||||||
|
|
||||||
|
wxAcceleratorEntry_v GetAccels()
|
||||||
|
{
|
||||||
|
return accels;
|
||||||
|
}
|
||||||
|
|
||||||
// the main configuration
|
// the main configuration
|
||||||
wxFileConfig* cfg;
|
wxFileConfig* cfg;
|
||||||
// vba-over.ini
|
// vba-over.ini
|
||||||
|
@ -230,6 +235,8 @@ public:
|
||||||
|
|
||||||
void SetJoystick();
|
void SetJoystick();
|
||||||
|
|
||||||
|
int FilterEvent(wxEvent& event);
|
||||||
|
|
||||||
GameArea* GetPanel()
|
GameArea* GetPanel()
|
||||||
{
|
{
|
||||||
return panel;
|
return panel;
|
||||||
|
|
Loading…
Reference in New Issue