Hi,
Does anyone have an idea if there is any wxWidgets way to detect whether any Modal Dialog box is open within the scope of the application?
While receiving certain events, I need to detect if there is any Modal dialog box (either custom Modal or File Open/File Save etc. Modal dialogs) are open or not.
Does wxWidgets provide a way to detect this? Or if someone even know any Mac specific API for this, that will help as well.
Thanks,
Hardik
How to detect if Modal dialog is open within application
-
- Earned a small fee
- Posts: 16
- Joined: Wed Apr 22, 2009 10:15 am
- Location: India
Re:
Can you please give a little more information? Posting a link to the wxWindow Class Reference documentation does not an answer to this question make. I do not see a IsDialogActive or IsFrameActive function in that class. I see a HasFocus function but I do not see how that can be used to answer the question of how to determine if a dialog box is open.
You need to provide a great deal more information.
- tierra
- Site Admin
- Posts: 1355
- Joined: Sun Aug 29, 2004 7:14 pm
- Location: Salt Lake City, Utah, USA
- Contact:
Re: How to detect if Modal dialog is open within application
The best idea I could maybe come up with is to use FindFocus(), and check if the containing top level window is a wxDialog, and checking that for wxDialog::IsModal().
That sounds like a fairly unreliable solution though (just because it's modal doesn't mean it necessarily has focus), and it would be better to hear why you need this because it's not something most applications need, and there's likely a much better approach to your problem, whatever it is.
If you still want to take that approach though, I'd highly recommend adding your own application-wide state (likely in your derived wxApp class) that you set whenever you open a modal dialog in your application. Just because wxWidgets doesn't provide it doesn't mean you can't still handle it yourself.
That sounds like a fairly unreliable solution though (just because it's modal doesn't mean it necessarily has focus), and it would be better to hear why you need this because it's not something most applications need, and there's likely a much better approach to your problem, whatever it is.
If you still want to take that approach though, I'd highly recommend adding your own application-wide state (likely in your derived wxApp class) that you set whenever you open a modal dialog in your application. Just because wxWidgets doesn't provide it doesn't mean you can't still handle it yourself.