logo       

Re: FXRuby usage: Capturing results from an FXDialogBox: msg#01149

lang.ruby.general

Subject: Re: FXRuby usage: Capturing results from an FXDialogBox

Stephan Kämper wrote:

Now, during querying the main program shouldn't be available, thus some
kind of modal dialog box seems appropriate.

Yes.

Up to now I wrote the following stuff, which is likely not the most elegant way, but let's follow the "Make it parse, make it work, make it nice, make it fast (IF neccessary" maxime for a moment. (But then I'm open for any improvements!)

<snip>

Now that doen't work: The dialog will never quit.
My guess is that the script never runs into code that sends something like ID_ACCEPT/ID_CANCEL to the appropriate object (which is self I think).

Your guess is exactly right. Once the dialog is displayed it needs some hint (such as an ID_ACCEPT or ID_CANCEL message) to tell it to go away.

What's the ruby way to accomplish this?

For most cases like this you shouldn't actually need to subclass FXDialogBox. I would recommend that you take a look at the imageviewer.rb example program that comes with FXRuby, because it pops up a few modal dialog boxes here and there to collect inputs from the user. In particular, take a look at the onCmdScale() and onCmdCrop() methods in that example.

I have the stron feeling that my way of fiddling with @result may not be too terribly rubyish - is there a better (Ruby) way to do this?

If you use the technique shown in the ImageViewer example, the user's selection should get mapped directly into an FXDataTarget. But another equally easy approach would be to check the two radio buttons to see which one is set (by calling FXRadioButton#check).

Hope this helps,

Lyle




<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise