Skip to content

Text input not working in wxPython (characters, tab, enter/return keys) - solutions available #152

Open
@GoogleCodeExporter

Description

@GoogleCodeExporter

Keyboard issues in wxPython may have multiple causes at the same time, so try apply all the fixes below until it works.

Issue 1/3

If characters don't work in inputs make sure you have set the wx.WANTS_CHARS style to all parent controls, including top level window.

Issue 2/3

Some wx controls may still cause issues and to resolve them is to remove the wx.TAB_TRAVERSAL style for all parent controls. See example function that removes such style recurrently for all parent controls:

def fixKeyboard(ctrl):
    while ctrl:
        ctrl.SetWindowStyle(ctrl.GetWindowStyle() & ~wx.TAB_TRAVERSAL)
        ctrl = ctrl.GetParent()

Issue 3/3

Some controls can still cause issues even with wx.WANTS_CHARS style applied and wx.TAB_TRAVERSAL style revmoed. For example when using the wx.aui.AuiNotebook control the TAB and RETURN (enter) keys don't work. To fix it you have to bind to wx.EVT_CHAR_HOOK and send these key events manually to CEF browser with the Browser.SendKeyEvent function. You can find sample code here: #508 (comment)

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions