From 2f6cb20d2ca3512d60cb15bca17fe4712d7818e5 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 9 Oct 2019 00:26:26 +0200 Subject: [PATCH] Stop intercepting Alt-Fn keys in the text sample This was annoying, especially under MSW, as Alt-F4 couldn't be used to close the application quickly. --- samples/text/text.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/samples/text/text.cpp b/samples/text/text.cpp index f4ee6f9038..309c505a95 100644 --- a/samples/text/text.cpp +++ b/samples/text/text.cpp @@ -995,6 +995,16 @@ void MyTextCtrl::OnKeyUp(wxKeyEvent& event) void MyTextCtrl::OnKeyDown(wxKeyEvent& event) { + if ( ms_logKey ) + LogKeyEvent( "Key down", event); + + event.Skip(); + + // Only handle bare function keys below, notably let Alt-Fn perform their + // usual default functions as intercepting them is annoying. + if ( event.GetModifiers() != 0 ) + return; + switch ( event.GetKeyCode() ) { case WXK_F1: @@ -1088,11 +1098,6 @@ void MyTextCtrl::OnKeyDown(wxKeyEvent& event) wxLogMessage("Control marked as non modified"); break; } - - if ( ms_logKey ) - LogKeyEvent( "Key down", event); - - event.Skip(); } //----------------------------------------------------------------------