From: Lyle Johnson Date: 2002-04-10T10:31:45+09:00 Subject: Re: FXRuby: subwindows > Problem 1: > 1) I've read that the main window is derived from FXMainWindow, but the > other windows are derived from such classes like FXDialogBox or FXTopWindow Yes, other *top-level* windows should be derived from either FXTopWindow or FXDialogBox. In this case, it should be a dialog box. > 2) FXDialogBox returns only true or false, and I don't want to use global > variables to handle the result in the sub window. I agree. You should instead create a new instance variable for your subclass of FXDialogBox (in my attached example, it's just called "@value"). The return value of FXDialogBox#execute is usually an integer indicating which terminator button (e.g. "OK" or "Cancel", "Yes" or "No") was pressed, but doesn't indicate anything about the data that the user provided in the dialog box. > 3) FXTopWindow doesn't support .new nor .show methods It does support show, but you're correct about it not supporting new. This is partially right, since FXTopWindow is an abstract base class and you're not supposed to instantiate one directly. But I think the way it's implemented in FXRuby that you can't subclass FXTopWindow and then call its initialize method; that's a problem I need to check out. > 4) I'm not sure about the syntax used to return the result OK, I've attached a modified version of your program which defines a new instance variable (@value) that stores the value of the last button pressed. After you display the dialog box, and the user clicks a button to dismiss it, your code should then retrieve the "value" of the dialog box. > Problem 2: > I've tried to use a FXPopup instead of the subwindow, which contained 4 > FXOptions instead of 4 buttons. I don't know how to: > - show this FXPopup when "click" is clicked > - return the result I'm not completely sure which effect you wanted with this version, so I'm going to choose the one that makes the most sense visually. Note that several of the FXRuby example programs demonstrate how to use the FXOptionMenu as well. First, create an empty FXPopup window that will hold the different option buttons: popup = FXPopup.new(self) Next, add option buttons (as children of the popup window) for each of the options: FXOption.new(popup, "1").connect(SEL_COMMAND) { @lbl.text = "1" } FXOption.new(popup, "2").connect(SEL_COMMAND) { @lbl.text = "2" } FXOption.new(popup, "3").connect(SEL_COMMAND) { @lbl.text = "3" } FXOption.new(popup, "4").connect(SEL_COMMAND) { @lbl.text = "4" } Finally, create the option menu itself: FXOptionMenu.new(vf, popup) This is the thing that the user will see and click on to "pop up" the popup menu we just created. It's the same concept as pulldown menus, where the user clicks on a menu title button and that pops up the menu choices. Hope this helps, Lyle begin 666 prog1.rb M T*#0IC;&%SF4H87!P*0T*("!S M=7!E'0@/2! T*(&%T=')? T*#0IC;&%SF4H87!P*0T*("!S M=7!E