I created a dialog (on the stack) inside a panel when a user clicks a button.
auto* btn_search_patient = new wxButton(panel, wxID_ANY, "Search");
btn_search_patient->Bind(wxEVT_BUTTON, [&](wxCommandEvent&) {
PatientSearcher dialog(this, eventQueue_);
config.applyTheme(&dialog);
dialog.ShowModal();
});
The dialog has a list inside that reacts to the user when he double clicks an item, the problem is that I needed to add a delay before exiting the modal:
PatientSearcher(wxWindow* parent, EventQueue& eventQueue)
: wxDialog(parent, wxID_ANY, "Patients", wxPoint(500, 1000), wxSize(800, 600)),
eventQueue_(eventQueue)
{
// ...
list_patients_->Bind(wxEVT_LIST_ITEM_ACTIVATED, [&](wxListEvent& event) {
...
std::this_thread::sleep_for(std::chrono::milliseconds(100));
EndModal(wxID_OK);
});
If I don't add that delay then the wxWidgets components that are exactly behind this modal react to this double click! So far as I understand modals are exactly to prevent this kind of actions. What may be the issue?
This looks very similar to a problem in wxFileDialog which was fixed by draining all the remaining mouse events after the dialog was dismissed. The same workaround could probably be applied in your case, see the commits linked from that issue.