[fxruby-users] FXTopWindow

angico angico at angico.org
Thu Nov 20 04:12:57 EST 2008

Em Qua, 2008-11-19 às 23:19 -0600, Jeroen van der Zijp escreveu:

> To get out of the modal loop, FXDialogBox calls app->stopModal(); this can
> be most easily accomplished via ID_CANCEL or ID_ACCEPT messages being sent
> to the dialogbox [they differ mainly in the return code passed along through
> runModalFor().
> You can certainly also call accept in response to a timeout.  In fact, handlers
> for timeout and chores have already been added to FXDialogBox: SEL_TIMEOUT,
> SEL_COMMAND, and SEL_CHORE with ID_CANCEL or ID_ACCEPT are available.
> So basically all that's needed is to set the timer to send the (SEL_TIMEOUT,ID_CANCEL)
> message to FXDialogBox at the desired time.
> Hope this helps,
> 		- Jeroen

Hi, Jeroen

I have already unsuccessfuly tried to exit an FXDialogBox's modal loop
all the ways I could think of - and none of them worked.

The basic idea for my timeout dialog box is:

class TimeoutDlg < FXDialogBox
  def execute
    time = 10

  def timer
    # give the user 5 seconds to respond, or accept the default
    while time > 0 do
      sleep 0.5
      time -= 1

    # my first trial, based on suggestion from Lyle
    handle(self, FXSEL(SEL_COMMAND, ID_ACCEPT), 0) # <-- doesn't work!!!

    # another trial, also based on Lyle's suggestion
    app.stopModal # <-- doesn't work!!!

    # my last trial, based on your suggestion
    handle(self, FXSEL(SEL_TIMEOUT, ID_ACCEPT), 0) # <-- doesn't work!!!

So, that's why I'm bound to create my own dialog, extending it from
FXTopWindow, but I don't know exactly how to do it, because when I
create the dialog with @dlg = TimeoutDlg, I got the error:

./timeoutdlg.rb:14:in `initialize': No matching function for overloaded
'new_FXTopWindow' (ArgumentError)
from ./timeoutdlg.rb:14:in `initialize'

Well, in my custom "initialize" I'm just using the same arguments to
FXComposite::initialize, which, according to the documentation, is the
"grandparent" of FXTopWindow.

That said, I'd like to ask you two things: 1) WHY doesn't ANY of the
trials to exit the FXDialogBox's modal loop work? And 2) HOW do I derive
or subclass from FXTopWindow (if not for this specific use, for any
other I might think of)?

I'm using:

ruby 1.8.6 (2007-09-24 patchlevel 111) [x86_64-linux]
FXRuby 1.6.16

I thank you very much, in advance.



home page: www.angico.org
Gnu/Linux, FLOSS, Espiritismo, e eu por mim mesmo 8^I

Cooperação é muito melhor que competição!

email: angico at angico.org
skype: an.gi.co

More information about the fxruby-users mailing list