Skip to content

Commit

Permalink
UI: Make Alt+F4/Ctrl+Q more reliable (#1035)
Browse files Browse the repository at this point in the history
  • Loading branch information
Squall-Leonhart authored Feb 18, 2024
1 parent 81acd80 commit 6a08d04
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/gui/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1485,6 +1485,19 @@ void MainWindow::OnKeyUp(wxKeyEvent& event)
g_window_info.has_screenshot_request = true; // async screenshot request
}

void MainWindow::OnKeyDown(wxKeyEvent& event)
{
if ((event.AltDown() && event.GetKeyCode() == WXK_F4) ||
(event.CmdDown() && event.GetKeyCode() == 'Q'))
{
Close(true);
}
else
{
event.Skip();
}
}

void MainWindow::OnChar(wxKeyEvent& event)
{
if (swkbd_hasKeyboardInputHook())
Expand Down Expand Up @@ -1590,6 +1603,7 @@ void MainWindow::CreateCanvas()

// key events
m_render_canvas->Bind(wxEVT_KEY_UP, &MainWindow::OnKeyUp, this);
m_render_canvas->Bind(wxEVT_KEY_DOWN, &MainWindow::OnKeyDown, this);
m_render_canvas->Bind(wxEVT_CHAR, &MainWindow::OnChar, this);

m_render_canvas->SetDropTarget(new wxAmiiboDropTarget(this));
Expand Down
1 change: 1 addition & 0 deletions src/gui/MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ class MainWindow : public wxFrame, public CafeSystem::SystemImplementation
void OnSetWindowTitle(wxCommandEvent& event);

void OnKeyUp(wxKeyEvent& event);
void OnKeyDown(wxKeyEvent& event);
void OnChar(wxKeyEvent& event);

void OnToolsInput(wxCommandEvent& event);
Expand Down

0 comments on commit 6a08d04

Please sign in to comment.