Replace Bind() call with an event table in Enter handling tests
For once, using the event table macros is preferable because this bypasses the (generally helpful, but not here) test done by Bind() verifying that wxEVT_TEXT_ENTER handler is bound to a window with wxTE_PROCESS_ENTER style. Doing it like this will allow to check that controls without this style really do not receive the corresponding event.
This commit is contained in:
@@ -398,11 +398,6 @@ public:
|
||||
m_processEnter(processEnter),
|
||||
m_gotEnter(false)
|
||||
{
|
||||
// We can't always bind this handler because wx will helpfully
|
||||
// complain if we bind it without using wxTE_PROCESS_ENTER.
|
||||
if ( processEnter != ProcessEnter_No )
|
||||
m_control->Bind(wxEVT_TEXT_ENTER, &TestDialog::OnTextEnter, this);
|
||||
|
||||
wxSizer* const sizer = new wxBoxSizer(wxVERTICAL);
|
||||
sizer->Add(m_control, wxSizerFlags().Expand());
|
||||
sizer->Add(CreateStdDialogButtonSizer(wxOK));
|
||||
@@ -455,8 +450,18 @@ private:
|
||||
const ProcessEnter m_processEnter;
|
||||
wxTimer m_timer;
|
||||
bool m_gotEnter;
|
||||
|
||||
wxDECLARE_EVENT_TABLE();
|
||||
};
|
||||
|
||||
// Note that we must use event table macros here instead of Bind() because
|
||||
// binding wxEVT_TEXT_ENTER handler for a control without wxTE_PROCESS_ENTER
|
||||
// style would fail with an assertion failure, due to wx helpfully complaining
|
||||
// about it.
|
||||
wxBEGIN_EVENT_TABLE(TestDialog, wxDialog)
|
||||
EVT_TEXT_ENTER(wxID_ANY, TestDialog::OnTextEnter)
|
||||
wxEND_EVENT_TABLE()
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
void TestProcessEnter(const TextLikeControlCreator& controlCreator)
|
||||
|
Reference in New Issue
Block a user