Any way to detect if a modal dialog is active?

I am bringing up a modal dialog based on a timer event, but I want to
detect if another modal dialog is currently active since it will mess
up the focus or mouse capture when you activate another modal dialog
at the same time such that nothing can be clicked.

Luke McCarthy wrote:

I am bringing up a modal dialog based on a timer event, but I want to
detect if another modal dialog is currently active since it will mess
up the focus or mouse capture when you activate another modal dialog
at the same time such that nothing can be clicked.

It's all under your control. Can't you just keep track of a global
"modal dialog is displayed" flag?

···

--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.

No, you'll probably need to maintain your own flag to keep track of whether a dialog is currently open.

···

On 6/14/11 8:00 AM, Luke McCarthy wrote:

I am bringing up a modal dialog based on a timer event, but I want to
detect if another modal dialog is currently active since it will mess
up the focus or mouse capture when you activate another modal dialog
at the same time such that nothing can be clicked.

--
Robin Dunn
Software Craftsman

Hi,

···

On Tue, Jun 14, 2011 at 12:37 PM, Robin Dunn <robin@alldunn.com> wrote:

On 6/14/11 8:00 AM, Luke McCarthy wrote:

I am bringing up a modal dialog based on a timer event, but I want to
detect if another modal dialog is currently active since it will mess
up the focus or mouse capture when you activate another modal dialog
at the same time such that nothing can be clicked.

No, you'll probably need to maintain your own flag to keep track of whether
a dialog is currently open.

Couldn't you check the windows list:

for win in wx.GetTopLevelWindows():
    if isinstance(win, wx.Dialog):
        if win.IsModal():
            # do something

Cody

Ah, I hadn't thought of that. Good idea.

···

On 6/14/11 10:42 AM, Cody Precord wrote:

Hi,

On Tue, Jun 14, 2011 at 12:37 PM, Robin Dunn<robin@alldunn.com> wrote:

On 6/14/11 8:00 AM, Luke McCarthy wrote:

I am bringing up a modal dialog based on a timer event, but I want to
detect if another modal dialog is currently active since it will mess
up the focus or mouse capture when you activate another modal dialog
at the same time such that nothing can be clicked.

No, you'll probably need to maintain your own flag to keep track of whether
a dialog is currently open.

Couldn't you check the windows list:

for win in wx.GetTopLevelWindows():
     if isinstance(win, wx.Dialog):
         if win.IsModal():
             # do something

--
Robin Dunn
Software Craftsman

wx.GetTopLevelWindows() somehow do not detect if wx.dirDialog is open. Is there any specific reason?

Nilay

···

On Tuesday, June 14, 2011 11:12:01 PM UTC+5:30, Cody Precord wrote:

Hi,
On Tue, Jun 14, 2011 at 12:37 PM, Robin Dunn ro...@alldunn.com wrote:

On 6/14/11 8:00 AM, Luke McCarthy wrote:

I am bringing up a modal dialog based on a timer event, but I want to
detect if another modal dialog is currently active since it will mess
up the focus or mouse capture when you activate another modal dialog
at the same time such that nothing can be clicked.

No, you’ll probably need to maintain your own flag to keep track of whether
a dialog is currently open.

Couldn’t you check the windows list:

for win in wx.GetTopLevelWindows():
if isinstance(win, wx.Dialog):
if win.IsModal():
# do something

Cody

Nilay Anand wrote:

wx.GetTopLevelWindows() somehow do not detect if wx.dirDialog is open.
Is there any specific reason?

Because it's not really a wx.Dialog, rather just a wrapper around a system API.

···

--
Robin Dunn
Software Craftsman