FXRuby - FXMainWindow question

I think that my problem is that I’ve got 2 classes that are both
subclassed from FXMainWindow, which I believe won’t work.

Here’s a short description of my data entry application and what I’m
trying to do. When my application is launched, the 1st FXMainWindow
class shows all of the data entries in my MySQL database.

The user can either double click on one of the FXTable cells or use
Ctrl-N to launch the 2nd FXMainWindow class, which is where the data
is shown so entry/update can be done.

My classes are launched the “standard” way:

if FILE == $0
FXApp.new(“Table”, “FXRuby”) do |app|
Table.new(app)
app.create
app.run
end
end

def create
super
show(PLACEMENT_SCREEN)
end

The error I’m getting when a cell in the table in the 1st
FXMainWindow class is clicked is undefined method `show’ because the
method I’m calling in the 2nd FXMainWindow class is a clone of the
above create method.

What would be the best way to change the application to make it work?
Any ideas are greatly appreciated.

TIA

John Reed

John Reed wrote:

I think that my problem is that I’ve got 2 classes that are both
subclassed from FXMainWindow, which I believe won’t work.

Possibly so; FOX version 1.0 really only supports one main window
(instance) per application. This problem is being addressed for FOX 1.2.

Here’s a short description of my data entry application and what I’m
trying to do. When my application is launched, the 1st FXMainWindow
class shows all of the data entries in my MySQL database.

OK.

The user can either double click on one of the FXTable cells or use
Ctrl-N to launch the 2nd FXMainWindow class, which is where the data
is shown so entry/update can be done.

Sounds like you might want to instead use a dialog box for that second
window (the entry/update window). See the dialog.rb example program
(among others) for an example of how to create and use custom dialog boxes.

The error I’m getting when a cell in the table in the 1st
FXMainWindow class is clicked is undefined method `show’ because the
method I’m calling in the 2nd FXMainWindow class is a clone of the
above create method.

I don’t follow this. The ‘show’ instance method is defined in FXWindow,
which is the base class for all of the windows & widgets in FOX.

What would be the best way to change the application to make it work?
Any ideas are greatly appreciated.

See previous recommendation about making the second window a dialog box.
From your brief description, it sounds like the 1st main window is
always shown, and is used primarily for display purposes; but the 2nd
window is transient, and used temporary to add or update table entries.

Hope this helps,

Lyle

Thanks for your suggestions, Lyle. I will work on implementing them.
When does FOX 1.2 come out?

John

John Reed wrote:

Thanks for your suggestions, Lyle. I will work on implementing them.
When does FOX 1.2 come out?

I have no idea, and that is completely out of my control. You might ask
Jeroen (FOX’s developer), but I can almost guarantee you that the answer
will be “it comes out when it comes out” :wink:

I did as you suggested and put the entry portion of my database on a
dialog box. I just issue this command to show the dialog box:

@@dialog.show

If I have the dialog box accept and cancel message identifiers tied
to a menu item, how can I capture what menu option was taken when the
control returns to my main class?

FXMenuCommand.new(filemenu, “&Accept”, nil, self, ID_ACCEPT)
FXMenuCommand.new(filemenu, “&Cancel”, nil, self, ID_CANCEL)

Thanks,

John

John Reed wrote:

I did as you suggested and put the entry portion of my database on a
dialog box. I just issue this command to show the dialog box:

@@dialog.show

If I have the dialog box accept and cancel message identifiers tied
to a menu item, how can I capture what menu option was taken when the
control returns to my main class?

FXMenuCommand.new(filemenu, “&Accept”, nil, self, ID_ACCEPT)
FXMenuCommand.new(filemenu, “&Cancel”, nil, self, ID_CANCEL)

If you were to display that dialog box modally (by calling execute), you
can just check the return value of FXDialogBox#execute, e.g.

 def showEntryDialog
   exitCode = @@dialog.execute
   if exitCode != 0
     # user clicked "Accept" to terminate the dialog box
   end
 end

If you’re displaying the dialog box non-modally (i.e. by just calling
show() on it) I don’t think that there is a way to directly recover
those termination codes.

Thanks, Lyle. That was the part I didn’t get even after looking at
your examples.

Is it true that you can’t call message identifiers like methods? So,
for example, I can’t create a method to force ID_CANCEL or ID_ACCEPT,
right?

Thanks,

John

John Reed wrote:

Is it true that you can’t call message identifiers like methods? So,
for example, I can’t create a method to force ID_CANCEL or ID_ACCEPT,
right?

Message identifiers are just numbers (constants) and so you cannot call
them like methods. Of course, Ruby makes it easy to add your own methods
to FXRuby classes to do just that, e.g.

 # Reopen class to add new methods...
 class FXDialogBox
   def doAccept
     handle(nil, MKUINT(ID_ACCEPT, SEL_COMMAND), nil)
   end
   def doCancel
     handle(nil, MKUINT(ID_CANCEL, SEL_COMMAND), nil)
   end
 end

Hope this helps,

Lyle