Avoid annoying beep when using Alt-Backspace in MSW text controls
Although the native (single line) text control understands Alt-Backspace as an accelerator for "Undo", using it was not really practical because it resulted in an annoying beep due to Alt-anything trying to find an item with matching mnemonic in the menu. Work around this native (mis)feature by pretending to handle this particular Alt-combination ourselves when the currently focused control is text-like, as indicated by it overriding WXGetTextEntry() -- this is not ideal, but seems to be the best we can currently do. An alternative could be to just mark Alt-Backspace as handled unconditionally.
This commit is contained in:
@@ -290,6 +290,22 @@ WXLRESULT wxTopLevelWindowMSW::MSWWindowProc(WXUINT message, WXWPARAM wParam, WX
|
||||
|
||||
DoRestoreLastFocus();
|
||||
}
|
||||
else if ( id == SC_KEYMENU )
|
||||
{
|
||||
// Alt-Backspace is understood as an accelerator for "Undo"
|
||||
// by the native EDIT control, but pressing it results in a
|
||||
// beep by default when the resulting SC_KEYMENU is handled
|
||||
// by DefWindowProc(), so pretend to handle it ourselves if
|
||||
// we're editing a text control to avoid the annoying beep.
|
||||
if ( lParam == VK_BACK )
|
||||
{
|
||||
if ( wxWindow* const focus = FindFocus() )
|
||||
{
|
||||
if ( focus->WXGetTextEntry() )
|
||||
processed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef __WXUNIVERSAL__
|
||||
// We need to generate events for the custom items added to the
|
||||
|
Reference in New Issue
Block a user