diff --git a/aegisub/src/audio_display.cpp b/aegisub/src/audio_display.cpp index d6f198dd0..bacb43ae6 100644 --- a/aegisub/src/audio_display.cpp +++ b/aegisub/src/audio_display.cpp @@ -1119,8 +1119,7 @@ void AudioDisplay::OnMouseEvent(wxMouseEvent& event) void AudioDisplay::OnKeyDown(wxKeyEvent& event) { - if (!hotkey::check("Audio", context, event.GetKeyCode(), event.GetUnicodeKey(), event.GetModifiers())) - event.Skip(); + hotkey::check("Audio", context, event); } void AudioDisplay::OnSize(wxSizeEvent &) diff --git a/aegisub/src/base_grid.cpp b/aegisub/src/base_grid.cpp index f4a54e159..a5fdac608 100644 --- a/aegisub/src/base_grid.cpp +++ b/aegisub/src/base_grid.cpp @@ -974,7 +974,7 @@ bool BaseGrid::IsDisplayed(const AssDialogue *line) const { } void BaseGrid::OnKeyDown(wxKeyEvent &event) { - if (hotkey::check("Subtitle Grid", context, event.GetKeyCode(), event.GetUnicodeKey(), event.GetModifiers())) + if (hotkey::check("Subtitle Grid", context, event)) return; int w,h; @@ -1044,9 +1044,8 @@ void BaseGrid::OnKeyDown(wxKeyEvent &event) { return; } } - else if (!hotkey::check("Audio", context, event.GetKeyCode(), event.GetUnicodeKey(), event.GetModifiers())) { - event.Skip(); - } + else + hotkey::check("Audio", context, event); } void BaseGrid::SetByFrame(bool state) { diff --git a/aegisub/src/dialog_detached_video.cpp b/aegisub/src/dialog_detached_video.cpp index a36a140d6..44071d594 100644 --- a/aegisub/src/dialog_detached_video.cpp +++ b/aegisub/src/dialog_detached_video.cpp @@ -117,8 +117,7 @@ void DialogDetachedVideo::OnMinimize(wxIconizeEvent &event) { } void DialogDetachedVideo::OnKeyDown(wxKeyEvent &evt) { - if (!hotkey::check("Video Display", context, evt.GetKeyCode(), evt.GetUnicodeKey(), evt.GetModifiers())) - evt.Skip(); + hotkey::check("Video Display", context, evt); } void DialogDetachedVideo::OnVideoOpen() { diff --git a/aegisub/src/dialog_styling_assistant.cpp b/aegisub/src/dialog_styling_assistant.cpp index f14142f17..816730ef7 100644 --- a/aegisub/src/dialog_styling_assistant.cpp +++ b/aegisub/src/dialog_styling_assistant.cpp @@ -247,7 +247,7 @@ void DialogStyling::OnPlayAudioButton(wxCommandEvent &) { } void DialogStyling::OnKeyDown(wxKeyEvent &evt) { - if (!hotkey::check("Styling Assistant", c, evt.GetKeyCode(), evt.GetUnicodeKey(), evt.GetModifiers())) { + if (!hotkey::check("Styling Assistant", c, evt)) { // Move the beginning of the selection back one character so that backspace // actually does something if (evt.GetKeyCode() == WXK_BACK && !evt.GetModifiers()) { diff --git a/aegisub/src/dialog_translation.cpp b/aegisub/src/dialog_translation.cpp index 2c16927ac..a336c4576 100644 --- a/aegisub/src/dialog_translation.cpp +++ b/aegisub/src/dialog_translation.cpp @@ -264,8 +264,7 @@ void DialogTranslation::InsertOriginal() { void DialogTranslation::OnKeyDown(wxKeyEvent &evt) { - if (!hotkey::check("Translation Assistant", c, evt.GetKeyCode(), evt.GetUnicodeKey(), evt.GetModifiers())) - evt.Skip(); + hotkey::check("Translation Assistant", c, evt); } void DialogTranslation::OnPlayVideoButton(wxCommandEvent &) { diff --git a/aegisub/src/frame_main.cpp b/aegisub/src/frame_main.cpp index aca6df4ae..e2fb0a487 100644 --- a/aegisub/src/frame_main.cpp +++ b/aegisub/src/frame_main.cpp @@ -683,8 +683,7 @@ void FrameMain::OnSubtitlesOpen() { } void FrameMain::OnKeyDown(wxKeyEvent &event) { - if (!hotkey::check("Main Frame", context.get(), event.GetKeyCode(), event.GetUnicodeKey(), event.GetModifiers())) - event.Skip(); + hotkey::check("Main Frame", context.get(), event); } void FrameMain::OnMouseWheel(wxMouseEvent &evt) { diff --git a/aegisub/src/hotkey.cpp b/aegisub/src/hotkey.cpp index 0a5ae74a1..24929ca32 100644 --- a/aegisub/src/hotkey.cpp +++ b/aegisub/src/hotkey.cpp @@ -133,6 +133,15 @@ bool check(std::string const& context, agi::Context *c, int key_code, wchar_t ke return false; } +bool check(std::string const& context, agi::Context *c, wxKeyEvent &evt) { + evt.StopPropagation(); + if (!hotkey::check(context, c, evt.GetKeyCode(), evt.GetUnicodeKey(), evt.GetModifiers())) { + evt.Skip(); + return false; + } + return true; +} + std::vector get_hotkey_strs(std::string const& context, std::string const& command) { return inst->GetHotkeys(context, command); } diff --git a/aegisub/src/include/aegisub/hotkey.h b/aegisub/src/include/aegisub/hotkey.h index 754450894..c6c9d3425 100644 --- a/aegisub/src/include/aegisub/hotkey.h +++ b/aegisub/src/include/aegisub/hotkey.h @@ -21,6 +21,8 @@ #ifndef AGI_PRE #include #include + +#include #endif namespace agi { @@ -35,6 +37,7 @@ extern agi::hotkey::Hotkey *inst; void init(); void clear(); +bool check(std::string const& context, agi::Context *c, wxKeyEvent &evt); bool check(std::string const& context, agi::Context *c, int key_code, wchar_t key_char, int modifier); std::string keypress_to_str(int key_code, wchar_t key_char, int modifier); std::string get_hotkey_str_first(std::string const& context, std::string const& command); diff --git a/aegisub/src/subs_edit_box.cpp b/aegisub/src/subs_edit_box.cpp index f33cdb615..cb65b05b7 100644 --- a/aegisub/src/subs_edit_box.cpp +++ b/aegisub/src/subs_edit_box.cpp @@ -400,8 +400,7 @@ void SubsEditBox::UpdateFrameTiming(agi::vfr::Framerate const& fps) { } void SubsEditBox::OnKeyDown(wxKeyEvent &event) { - if (!hotkey::check("Subtitle Edit Box", c, event.GetKeyCode(), event.GetUnicodeKey(), event.GetModifiers())) - event.Skip(); + hotkey::check("Subtitle Edit Box", c, event); } void SubsEditBox::OnChange(wxStyledTextEvent &event) { diff --git a/aegisub/src/video_display.cpp b/aegisub/src/video_display.cpp index 02dce1dbb..59a2d80c2 100644 --- a/aegisub/src/video_display.cpp +++ b/aegisub/src/video_display.cpp @@ -389,8 +389,7 @@ void VideoDisplay::OnContextMenu(wxContextMenuEvent&) { } void VideoDisplay::OnKeyDown(wxKeyEvent &event) { - if (!hotkey::check("Video", con, event.GetKeyCode(), event.GetUnicodeKey(), event.GetModifiers())) - event.Skip(); + hotkey::check("Video", con, event); } void VideoDisplay::SetZoom(double value) { diff --git a/aegisub/src/video_slider.cpp b/aegisub/src/video_slider.cpp index d0a625fed..4b1d0d760 100644 --- a/aegisub/src/video_slider.cpp +++ b/aegisub/src/video_slider.cpp @@ -149,7 +149,7 @@ void VideoSlider::OnMouse(wxMouseEvent &event) { } void VideoSlider::OnKeyDown(wxKeyEvent &event) { - if (hotkey::check("Video", c, event.GetKeyCode(), event.GetUnicodeKey(), event.GetModifiers())) + if (hotkey::check("Video", c, event)) return; // Forward up/down to grid as those aren't yet handled by commands