From c4f49d69cfbd1adbb3460d3a836b671b5126510b Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 29 Jul 2012 22:08:21 +0000 Subject: [PATCH] Make keyboard sample output less confusing. Warn if key presses occur when the input window doesn't have focus as the usual key events are not generated then which could be understood as a bug in the sample instead of the correct result. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72253 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- samples/keyboard/keyboard.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/samples/keyboard/keyboard.cpp b/samples/keyboard/keyboard.cpp index 7b30978965..f17ffb4b98 100644 --- a/samples/keyboard/keyboard.cpp +++ b/samples/keyboard/keyboard.cpp @@ -54,6 +54,16 @@ private: void OnChar(wxKeyEvent& event) { LogEvent("Char", event); } void OnCharHook(wxKeyEvent& event) { + // The logged messages can be confusing if the input window doesn't + // have focus so warn about this. + if ( !m_inputWin->HasFocus() ) + { + m_logText->SetDefaultStyle(*wxRED); + m_logText->AppendText("WARNING: focus is not on input window, " + "non-hook events won't be logged.\n"); + m_logText->SetDefaultStyle(wxTextAttr()); + } + LogEvent("Hook", event); if ( m_skipHook ) event.Skip(); @@ -167,7 +177,7 @@ MyFrame::MyFrame(const wxString& title) m_logText = new wxTextCtrl(this, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, - wxTE_MULTILINE|wxTE_READONLY|wxHSCROLL); + wxTE_MULTILINE|wxTE_READONLY|wxTE_RICH|wxHSCROLL); // set monospace font to have output in nice columns wxFont font(10, wxFONTFAMILY_TELETYPE, -- 2.47.2