]> git.saurik.com Git - wxWidgets.git/commitdiff
Make keyboard sample output less confusing.
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 29 Jul 2012 22:08:21 +0000 (22:08 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 29 Jul 2012 22:08:21 +0000 (22:08 +0000)
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

index 7b30978965f62eefc81f76a36b7760ca490f43c8..f17ffb4b9835d43520b44c3081c2bc843dc862b4 100644 (file)
@@ -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,