Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3317108
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T22:32:55+00:00 2026-05-17T22:32:55+00:00

I am maintaining a wxWidgets C++ application that uses EVT_CHAR_HOOK to capture key events

  • 0

I am maintaining a wxWidgets C++ application that uses EVT_CHAR_HOOK to capture key events in a high level window. I can’t find any real documentation for this event but I can surmise that it intercepts key events in some way that has priority over the “standard” key events. One disturbing thing that I just discovered is that, if this hook is in place, any accelerator keys that might have been defined will no longer fire their events even if the event handler calls Skip() on the event. I’ve also seen some posts when searching on google that seemed to suggest that EVT_CHAR_HOOK may not be supported on all platforms. Is this true and should I be using it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T22:32:56+00:00Added an answer on May 17, 2026 at 10:32 pm

    I just looked into src/gtk/window.cpp and found this piece:

            // Implement OnCharHook by checking ancestor top level windows
            wxWindow *parent = win;
            while (parent && !parent->IsTopLevel())
                parent = parent->GetParent();
            if (parent)
            {
                event.SetEventType( wxEVT_CHAR_HOOK );
                ret = parent->HandleWindowEvent( event );
            }
    
            if (!ret)
            {
                event.SetEventType(wxEVT_CHAR);
                ret = win->HandleWindowEvent( event );
            }
    

    So, maybe you just need to return false from your OnCharHook event handler?

    In accordance to one of wx Mailing list post:

    If you want the frame to catch all char events, use EVT_CHAR_HOOK, otherwise the events get sent to the children. If you want to catch stuff like escape, you need to set wxWANTS_CHARS flag on the frame. Also, make sure you call event.Skip() on chars you don’t process.

    But another post states:

    …don’t use EVT_CHAR_HOOK(), it is a hack. Moreover, it is a Windows-specific hack and
    I’m personally not at all interested in getting it to work right. If anything,
    I’d like to deprecate it and get rid of it completely. VZ.

    This post may be of interest to you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm maintaining some code that uses a *= operator in a query to a
I'm maintaining a legacy application, and I need to find the documentation for the
I am maintaining an OO PHP application that loads everything to $this array. When
I am maintaining an app for a client that is used in two locations.
I'm maintaining a .NET 1.1 application and one of the things I've been tasked
Maintaining unit tests is difficult. I am sure that we all have experienced a
While maintaining an old product, I came across an error that results in the
The intent is to create a set of web services that people can reuse.
Maintaining an signed applet that opens connections to the server it was downloaded from.
When maintaining a COM interface should an empty BSTR be treated the same way

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.