Lyle Johnson
2007-Dec-05 15:31 UTC
[fxruby-users] [Foxgui-users] Stopping a FOX popup window
On 12/4/07, Thomas, Jason M (Software) <jmthomas at ball.com> wrote:> I''m using the FXRuby bindings to FOX and trying to use the unit test > framework to do some testing. I''ve been able to create and tear down my FOX > applications successfully but I''m having trouble programmatically closing a > dialog box. I''ve tried (FXApp) stop and stopModal but they don''t seem to > have any effect. Closing and destroying the window works but the code is > still stuck in the application loop.Your code doesn''t create a dialog box, it creates a second main window. Is that what you meant to do? At any rate, you should be able to break out of the runPopup() loop by calling hide() on the window: def test_exception_popup() Thread.new do sleep(2) app = FXApp.instance app.activeWindow.hide end ... end Hope this helps, Lyle
Thomas, Jason M (Software)
2007-Dec-05 15:49 UTC
[fxruby-users] [Foxgui-users] Stopping a FOX popup window
That worked great! I''m just curious why I was going down the wrong path. Was it because I called runPopup with a FXMainWindow? Does runPopup only work with a FXPopup? When should FXApp.stop be called? I tried the following: popup = FXPopup.new(window) popup.popup(nil, 0, 0) application.runPopup(popup) At this point the popup window appeared. Then in my other thread I did: sleep(2) app = FXApp.instance app.stop This results in a Segmentation fault. Any ideas? Thanks again for helping me. Right now I''m just trying to understand how FOX works. Jason -----Original Message----- From: Lyle Johnson [mailto:lyle at lylejohnson.name] Sent: Wednesday, December 05, 2007 8:31 AM To: Thomas, Jason M (Software) Cc: foxgui-users at lists.sourceforge.net; fxruby-users at rubyforge.org Subject: Re: [Foxgui-users] Stopping a FOX popup window On 12/4/07, Thomas, Jason M (Software) <jmthomas at ball.com> wrote:> I''m using the FXRuby bindings to FOX and trying to use the unit test > framework to do some testing. I''ve been able to create and tear down > my FOX applications successfully but I''m having trouble > programmatically closing a dialog box. I''ve tried (FXApp) stop and > stopModal but they don''t seem to have any effect. Closing and > destroying the window works but the code is still stuck in theapplication loop. Your code doesn''t create a dialog box, it creates a second main window. Is that what you meant to do? At any rate, you should be able to break out of the runPopup() loop by calling hide() on the window: def test_exception_popup() Thread.new do sleep(2) app = FXApp.instance app.activeWindow.hide end ... end Hope this helps, Lyle This message and any enclosures are intended only for the addressee. Please notify the sender by email if you are not the intended recipient. If you are not the intended recipient, you may not use, copy, disclose, or distribute this message or its contents or enclosures to any other person and any such actions may be unlawful. Ball reserves the right to monitor and review all messages and enclosures sent to or from this email address.
Lyle Johnson
2007-Dec-05 18:14 UTC
[fxruby-users] [Foxgui-users] Stopping a FOX popup window
On 12/5/07, Thomas, Jason M (Software) <jmthomas at ball.com> wrote:> That worked great! I''m just curious why I was going down the wrong path. > Was it because I called runPopup with a FXMainWindow?Yes.> Does runPopup only work with a FXPopup?Well, it''s only meant to work with popups, but since it accepts an FXWindow argument, you can (as you discovered) pass in any kind of window. runPopup() is one of those methods that I think probably shouldn''t be public, because it''s really sort of a special purpose method that FOX only uses internally (as best I can tell). Maybe Jeroen will interject with some words of wisdom on this point. ;)> When should FXApp.stop be called?stop() breaks out of all of the (possibly many) nested event loops, to the very top one, which eventually causes your program to fall out of the top-level run().> I tried the following: > popup = FXPopup.new(window) > popup.popup(nil, 0, 0) > application.runPopup(popup) > > At this point the popup window appeared. Then in my other thread I did: > sleep(2) > app = FXApp.instance > app.stop > > This results in a Segmentation fault. Any ideas?Well, I''m not really sure what it is that you''re trying to do. For example, I don''t understand why you''ve fixated on popups (which are primarily used for things like tooltips and menu panes). But since runPopup() starts a modal event loop for the popup window, the way to shut it down would be to either call stopModal(), or to just hide the popup (as I showed earlier). If you''re wanting to display a little informational message to the user, I think you want to take a look at FXMessageBox. Or maybe FXDialogBox, if FXMessageBox doesn''t quite give you all of the control that you need.> Thanks again for helping me. Right now I''m just trying to understand how > FOX works.No problem! We''re all learning. ;)
Jeroen van der Zijp
2007-Dec-05 20:09 UTC
[fxruby-users] [Foxgui-users] Stopping a FOX popup window
On Wednesday 05 December 2007, Lyle Johnson wrote:> On 12/5/07, Thomas, Jason M (Software) <jmthomas at ball.com> wrote: > > > That worked great! I''m just curious why I was going down the wrong path. > > Was it because I called runPopup with a FXMainWindow? > > Yes. > > > Does runPopup only work with a FXPopup? > > Well, it''s only meant to work with popups, but since it accepts an > FXWindow argument, you can (as you discovered) pass in any kind of > window. runPopup() is one of those methods that I think probably > shouldn''t be public, because it''s really sort of a special purpose > method that FOX only uses internally (as best I can tell). Maybe > Jeroen will interject with some words of wisdom on this point. ;)I do think we would be able to change the type from FXWindow to FXPopup, to kill any possible confusion about what its supposed to be used for.> > When should FXApp.stop be called? > > stop() breaks out of all of the (possibly many) nested event loops, to > the very top one, which eventually causes your program to fall out of > the top-level run().Right! All the recursive invocations of event loops are added into a linked list, with the head being the innermost loop. FXApp::stop() sets the stop flag on all the loops; FXApp::stopModal(window) stops all loops up to and including the one associated with the given window. It will appear to the application as if all modal dialogs have been cancelled. - Jeroen