mirror of
https://github.com/cookiengineer/audacity
synced 2025-10-20 17:41:13 +02:00
Bug 2107 - Mac Accessibility: if a text box is the focus, pressing enter does not press the default button
Adapted very slightly from Paul's fix and pull request. See also Bug 1329.
This commit is contained in:
@@ -190,6 +190,26 @@ public:
|
|||||||
if ( !( sPreFilter() && sPreFilter()( key ) ) )
|
if ( !( sPreFilter() && sPreFilter()( key ) ) )
|
||||||
return Event_Skip;
|
return Event_Skip;
|
||||||
|
|
||||||
|
#ifdef __WXMAC__
|
||||||
|
// Bug 2107 (Mac only)
|
||||||
|
// wxButton::SetDefault() alone doesn't cause correct event routing
|
||||||
|
// of key-down to the button when a text entry or combo has focus,
|
||||||
|
// but we can intercept wxEVT_CHAR_HOOK here and do it
|
||||||
|
if ( type == wxEVT_CHAR_HOOK &&
|
||||||
|
key.GetKeyCode() == WXK_RETURN ) {
|
||||||
|
if (auto top =
|
||||||
|
dynamic_cast< wxTopLevelWindow* >(
|
||||||
|
wxGetTopLevelParent( wxWindow::FindFocus() ) ) ) {
|
||||||
|
if ( auto button =
|
||||||
|
dynamic_cast<wxButton*>( top->GetDefaultItem() ) ) {
|
||||||
|
wxCommandEvent newEvent{ wxEVT_BUTTON, button->GetId() };
|
||||||
|
button->GetEventHandler()->AddPendingEvent( newEvent );
|
||||||
|
return Event_Processed;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// Make a copy of the event and (possibly) make it look like a key down
|
// Make a copy of the event and (possibly) make it look like a key down
|
||||||
// event.
|
// event.
|
||||||
if (type == wxEVT_CHAR_HOOK)
|
if (type == wxEVT_CHAR_HOOK)
|
||||||
|
Reference in New Issue
Block a user