don't restore the focus manually after closing the dialog, default Windows behaviour seems to work just fine now (see #10240)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@57453 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -120,8 +120,6 @@ private:
|
|||||||
// gripper if we have one
|
// gripper if we have one
|
||||||
void OnWindowCreate(wxWindowCreateEvent& event);
|
void OnWindowCreate(wxWindowCreateEvent& event);
|
||||||
|
|
||||||
|
|
||||||
wxWindow* m_oldFocus;
|
|
||||||
bool m_endModalCalled; // allow for closing within InitDialog
|
bool m_endModalCalled; // allow for closing within InitDialog
|
||||||
|
|
||||||
#if wxUSE_TOOLBAR && defined(__POCKETPC__)
|
#if wxUSE_TOOLBAR && defined(__POCKETPC__)
|
||||||
|
@@ -145,7 +145,6 @@ wxDEFINE_TIED_SCOPED_PTR_TYPE(wxDialogModalData)
|
|||||||
|
|
||||||
void wxDialog::Init()
|
void wxDialog::Init()
|
||||||
{
|
{
|
||||||
m_oldFocus = (wxWindow *)NULL;
|
|
||||||
m_isShown = false;
|
m_isShown = false;
|
||||||
m_modalData = NULL;
|
m_modalData = NULL;
|
||||||
m_endModalCalled = false;
|
m_endModalCalled = false;
|
||||||
@@ -165,9 +164,6 @@ bool wxDialog::Create(wxWindow *parent,
|
|||||||
{
|
{
|
||||||
SetExtraStyle(GetExtraStyle() | wxTOPLEVEL_EX_DIALOG);
|
SetExtraStyle(GetExtraStyle() | wxTOPLEVEL_EX_DIALOG);
|
||||||
|
|
||||||
// save focus before doing anything which can potentially change it
|
|
||||||
m_oldFocus = FindFocus();
|
|
||||||
|
|
||||||
// All dialogs should really have this style
|
// All dialogs should really have this style
|
||||||
style |= wxTAB_TRAVERSAL;
|
style |= wxTAB_TRAVERSAL;
|
||||||
|
|
||||||
@@ -294,45 +290,10 @@ int wxDialog::ShowModal()
|
|||||||
// into account
|
// into account
|
||||||
if ( !m_endModalCalled )
|
if ( !m_endModalCalled )
|
||||||
{
|
{
|
||||||
// modal dialog needs a parent window, so try to find one
|
|
||||||
wxWindow *parent = GetParent();
|
|
||||||
if ( !parent )
|
|
||||||
{
|
|
||||||
parent = FindSuitableParent();
|
|
||||||
}
|
|
||||||
|
|
||||||
// remember where the focus was
|
|
||||||
wxWindow *oldFocus = m_oldFocus;
|
|
||||||
if ( !oldFocus )
|
|
||||||
{
|
|
||||||
// VZ: do we really want to do this?
|
|
||||||
oldFocus = parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
// We have to remember the HWND because we need to check
|
|
||||||
// the HWND still exists (oldFocus can be garbage when the dialog
|
|
||||||
// exits, if it has been destroyed)
|
|
||||||
HWND hwndOldFocus = oldFocus ? GetHwndOf(oldFocus) : NULL;
|
|
||||||
|
|
||||||
|
|
||||||
// enter and run the modal loop
|
// enter and run the modal loop
|
||||||
{
|
wxDialogModalDataTiedPtr modalData(&m_modalData,
|
||||||
wxDialogModalDataTiedPtr modalData(&m_modalData,
|
new wxDialogModalData(this));
|
||||||
new wxDialogModalData(this));
|
modalData->RunLoop();
|
||||||
modalData->RunLoop();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// and restore focus
|
|
||||||
// Note that this code MUST NOT access the dialog object's data
|
|
||||||
// in case the object has been deleted (which will be the case
|
|
||||||
// for a modal dialog that has been destroyed before calling EndModal).
|
|
||||||
if ( oldFocus && (oldFocus != this) && ::IsWindow(hwndOldFocus))
|
|
||||||
{
|
|
||||||
// This is likely to prove that the object still exists
|
|
||||||
if (wxFindWinFromHandle((WXHWND) hwndOldFocus) == oldFocus)
|
|
||||||
oldFocus->SetFocus();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return GetReturnCode();
|
return GetReturnCode();
|
||||||
|
Reference in New Issue
Block a user