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:
@@ -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() )
|
||||
|
Reference in New Issue
Block a user