如何使 wxAcceleratorTable 与 wxFrame 和 wxTextCtrl 一起工作?

How do I make wxAcceleratorTable work with wxFrame and wxTextCtrl?

我在 wxFrame 上有一个 wxTextControl 和一个 wxButton,我希望 Shift+Enter 使按钮被点击。 wxAcceleratorTable documentation 表示这是可能的:

"For example, you can use an accelerator table to enable a dialog with a multi-line text control to accept CTRL-Enter as meaning 'OK'."

我无法让它工作。你能给我一个简短的例子,说明如何一起使用 wxFrame、wxTextControl、wxButton 和 wxAcceleratorTable 吗?

事实证明,wxAcceleratorTable 只能在 wxGTK 上与 wxEVT_MENU 一起使用。所以代码看起来像这样:

wxAcceleratorEntry shiftReturn(wxACCEL_SHIFT, WXK_RETURN, wxID_BACKWARD);
SetAcceleratorTable(wxAcceleratorTable(1, &shiftReturn));
Bind(wxEVT_MENU, &FindFrame::OnPrev, this, wxID_BACKWARD);

相反,我们决定使用 GTK 的本机加速器和 OSX 而不是 wx 加速器,这样键盘快捷键就会为目标按钮设置动画。参见 604cdb5, b00a76e, and 91a8d2a at Poedit's GitHub page