]> git.saurik.com Git - wxWidgets.git/commitdiff
Fix example of using GetUnicodeKey() in the documentation.
authorVadim Zeitlin <vadim@wxwidgets.org>
Fri, 31 Aug 2012 12:31:44 +0000 (12:31 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Fri, 31 Aug 2012 12:31:44 +0000 (12:31 +0000)
A Unicode key is not always printable, it can be a control character as well.

Closes #14622.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72420 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

interface/wx/event.h

index d02d5a0d377fd0d2e61b09fa32972b949ee85b06..9f75e9a785403beca3663529e1e0938d76b8e0c1 100644 (file)
@@ -1406,12 +1406,23 @@ public:
         @code
             void MyHandler::OnChar(wxKeyEvent& event)
             {
-                if ( event.GetUnicodeKey() != WXK_NONE )
+                wxChar uc = event.GetUnicodeKey();
+                if ( uc != WXK_NONE )
                 {
-                    // It's a printable character
-                    wxLogMessage("You pressed '%c'", event.GetUnicodeKey());
+                    // It's a "normal" character. Notice that this includes
+                    // control characters in 1..31 range, e.g. WXK_RETURN or
+                    // WXK_BACK.
+                    if ( wxIsprint(uc) )
+                    {
+                        wxLogMessage("You pressed '%c'", uc);
+                    }
+                    else
+                    {
+                        // It's a control character
+                        ...
+                    }
                 }
-                else
+                else // No Unicode equivalent.
                 {
                     // It's a special key, deal with all the known ones:
                     switch ( GetKeyCode() )