Fix example of using GetUnicodeKey() in the documentation.

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
This commit is contained in:
Vadim Zeitlin
2012-08-31 12:31:44 +00:00
parent f5462b02b8
commit 9a1b36af5a

View 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() )