Fix restoring focus after showing native modal dialogs in wxMSW
This fixes a regression introduced in d311c705d7 (Make native dialogs
application-modal in wxMSW, 2022-04-01) which resulted in a focus loss
after showing a modal dialog, as the parent window was still disabled
when the native modal dialog was closed and so focus couldn't be set to
any of its children and was simply lost as the result.
Fix this by not disabling the dialog parent ourselves, but leaving
handling the parent status to the native modal dialog, which already
takes care of disabling the parent it uses when it is shown and
re-enabling it when it is dismissed. Still use wxWindowDisabler to
disable all the other top level windows, if any, to ensure that the
modal dialogs are truly app-modal and not just window-modal, i.e. ensure
that #11887 still remains fixed.
Closes #22285.
This commit is contained in:
@@ -177,7 +177,7 @@ int wxColourDialog::ShowModal()
|
||||
{
|
||||
WX_HOOK_MODAL_DIALOG();
|
||||
|
||||
wxWindowDisabler disableOthers(this);
|
||||
wxWindowDisabler disableOthers(this, GetParent());
|
||||
|
||||
wxWindow* const parent = GetParentForModalDialog(m_parent, GetWindowStyle());
|
||||
WXHWND hWndParent = parent ? GetHwndOf(parent) : NULL;
|
||||
|
||||
@@ -152,7 +152,7 @@ int wxDirDialog::ShowModal()
|
||||
{
|
||||
WX_HOOK_MODAL_DIALOG();
|
||||
|
||||
wxWindowDisabler disableOthers(this);
|
||||
wxWindowDisabler disableOthers(this, GetParent());
|
||||
|
||||
wxWindow* const parent = GetParentForModalDialog();
|
||||
WXHWND hWndParent = parent ? GetHwndOf(parent) : NULL;
|
||||
|
||||
@@ -430,7 +430,7 @@ int wxFileDialog::ShowModal()
|
||||
{
|
||||
WX_HOOK_MODAL_DIALOG();
|
||||
|
||||
wxWindowDisabler disableOthers(this);
|
||||
wxWindowDisabler disableOthers(this, GetParent());
|
||||
|
||||
wxWindow* const parent = GetParentForModalDialog(m_parent, GetWindowStyle());
|
||||
WXHWND hWndParent = parent ? GetHwndOf(parent) : NULL;
|
||||
|
||||
@@ -92,7 +92,7 @@ int wxFontDialog::ShowModal()
|
||||
{
|
||||
WX_HOOK_MODAL_DIALOG();
|
||||
|
||||
wxWindowDisabler disableOthers(this);
|
||||
wxWindowDisabler disableOthers(this, GetParent());
|
||||
|
||||
wxWindow* const parent = GetParentForModalDialog(m_parent, GetWindowStyle());
|
||||
WXHWND hWndParent = parent ? GetHwndOf(parent) : NULL;
|
||||
|
||||
@@ -539,7 +539,7 @@ int wxMessageDialog::ShowModal()
|
||||
{
|
||||
WX_HOOK_MODAL_DIALOG();
|
||||
|
||||
wxWindowDisabler disableOthers(this);
|
||||
wxWindowDisabler disableOthers(this, GetParent());
|
||||
|
||||
#ifdef wxHAS_MSW_TASKDIALOG
|
||||
if ( HasNativeTaskDialog() )
|
||||
|
||||
@@ -806,7 +806,7 @@ int wxWindowsPrintDialog::ShowModal()
|
||||
{
|
||||
WX_HOOK_MODAL_DIALOG();
|
||||
|
||||
wxWindowDisabler disableOthers(this);
|
||||
wxWindowDisabler disableOthers(this, GetParent());
|
||||
|
||||
wxWindow* const parent = GetParentForModalDialog(m_parent, GetWindowStyle());
|
||||
WXHWND hWndParent = parent ? GetHwndOf(parent) : NULL;
|
||||
|
||||
@@ -37,7 +37,7 @@ int wxRichMessageDialog::ShowModal()
|
||||
|
||||
if ( HasNativeTaskDialog() )
|
||||
{
|
||||
wxWindowDisabler disableOthers(this);
|
||||
wxWindowDisabler disableOthers(this, GetParent());
|
||||
|
||||
// create a task dialog
|
||||
WinStruct<TASKDIALOGCONFIG> tdc;
|
||||
|
||||
Reference in New Issue
Block a user