Open wxtrac opened 12 years ago
This is due to the deferred show mechanism wxTopLevelWindow now uses to determine window decoration sizes. Note that this only happens if you show a dialog before your frame is actually visible.
That's good to know. Called Raise() on the main frame (in addition to Show()) before calling ShowModal() on the dialog box seems to be a work-around.
Issue migrated from trac ticket # 14441
component: wxGTK | priority: normal | keywords: wxDialog ShowModal focus
2012-06-28 05:23:43: mawicks0930 (Mark A. Wicks) created the issue
For custom dialog boxes derived from wxDialog, ShowModal() does not give focus to the dialog box unless a "standard" dialog box is displayed first. This did not occur in wxWidgets 2.8.x.
The following code shows the problem using a minimal version of OnInit() with the MyModalDialog class from samples/dialogs/dialogs.cpp):
include <wx/wx.h>
class MyApp: public wxApp { public: MyApp() { }
};
// A custom modal dialog class MyModalDialog : public wxDialog { public: MyModalDialog(wxWindow *parent);
private: wxButton* m_btn; };
IMPLEMENT_APP(MyApp)
bool MyApp::OnInit() { if ( !wxApp::OnInit() ) return false;
_ Define AVOID_BUG and everything works fine. Without AVOIDBUG, the MyModalDialog doesn't get focus.
ifdef AVOID_BUG
endif
} ---------------------------------------------------------------------------- MyModalDialog // ----------------------------------------------------------------------------
MyModalDialog::MyModalDialog(wxWindow parent) : wxDialog(parent, wxID_ANY, wxString(wxT("Modal dialog"))) { wxBoxSizer sizerTop = new wxBoxSizer(wxHORIZONTAL);
}