Fix uppercase 'X' in text controls when menu accelerator steals key event
On macOS, menu accelerators intercept key events before they reach focused text controls. The existing workaround in ACTION_MENU::OnMenuEvent re-creates the key event but uses the raw key code (always uppercase for letters) when converting. Fix by checking the actual Shift/CapsLock keyboard state and converting the key code to the correct case before forwarding the synthetic wxEVT_CHAR event. Row 53
This commit is contained in:
committed by
Seth Hillbrand
parent
58e98bb999
commit
3be5046f0f
@@ -471,6 +471,26 @@ void ACTION_MENU::OnMenuEvent( wxMenuEvent& aEvent )
|
||||
if( keyEvent.GetSkipped() )
|
||||
{
|
||||
keyEvent.SetEventType( wxEVT_CHAR );
|
||||
|
||||
// CHAR_HOOK always uses uppercase key codes for letters, but
|
||||
// wxEVT_CHAR should use the translated (case-correct) character.
|
||||
// Since the original key event was lost to the menu system, check
|
||||
// the actual keyboard state to determine proper case.
|
||||
int keyCode = keyEvent.GetKeyCode();
|
||||
|
||||
if( keyCode >= 'A' && keyCode <= 'Z' )
|
||||
{
|
||||
bool shiftActive = wxGetKeyState( WXK_SHIFT );
|
||||
bool capsActive = wxGetKeyState( WXK_CAPITAL );
|
||||
|
||||
if( !( shiftActive ^ capsActive ) )
|
||||
keyEvent.m_keyCode = keyCode + 32; // Convert to lowercase
|
||||
}
|
||||
|
||||
#if wxUSE_UNICODE
|
||||
keyEvent.m_uniChar = keyEvent.m_keyCode;
|
||||
#endif
|
||||
|
||||
focus->HandleWindowEvent( keyEvent );
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user