Fix forwarding of menu commands in the richtext sample

Fall back on the main rich text control if there is no currently focused
window, as the control itself never has focus when a menu is opened with
wxGTK/Wayland, i.e. none of the menu commands, such as wxID_COPY/CUT,
worked for it in this case.

Closes #22121.
This commit is contained in:
Vadim Zeitlin
2022-03-26 18:21:59 +01:00
parent 7e45373e16
commit 0390951677

View File

@@ -757,6 +757,8 @@ MyFrame::MyFrame(const wxString& title, wxWindowID id, const wxPoint& pos,
const wxSize& size, long style) const wxSize& size, long style)
: wxFrame(NULL, id, title, pos, size, style) : wxFrame(NULL, id, title, pos, size, style)
{ {
m_richTextCtrl = NULL;
#ifdef __WXMAC__ #ifdef __WXMAC__
SetWindowVariant(wxWINDOW_VARIANT_SMALL); SetWindowVariant(wxWINDOW_VARIANT_SMALL);
#endif #endif
@@ -1339,6 +1341,8 @@ bool MyFrame::ProcessEvent(wxEvent& event)
s_id = event.GetId(); s_id = event.GetId();
wxWindow* focusWin = wxFindFocusDescendant(this); wxWindow* focusWin = wxFindFocusDescendant(this);
if (!focusWin)
focusWin = m_richTextCtrl;
if (focusWin && focusWin->GetEventHandler()->ProcessEvent(event)) if (focusWin && focusWin->GetEventHandler()->ProcessEvent(event))
{ {
//s_command = NULL; //s_command = NULL;