Some pointers needed on FXRuby-based app

I’m teaching myself Ruby by way of building an application using
FXRuby. I’ve gotten to the point where I have a functioning GUI,
and I can create dialogue boxes containing data extracted from a
database. However I’m having difficulty working out how to get the
data from the dialogue box form back into the application.

I’m used to dealing with web-based scripts written in PHP where all
data is posted into the server so the adjustment to client
application coding is proving a little difficult!

I’ve attempted to figure it out by studying the textedit
application that was bundled with the Ruby installation, but I’m
not quite getting it, and although the class documentation for Fox
is quite good actual usage examples are almost nonexistant.

I’ve posted the source code for my dialogue form at
http://www.flatnet.net/ruby/EditUserDialog.rb.html. If anyone could
give me some hints on how to proceed then I would be grateful.

···


Phil Roberts | Without me its just aweso. | http://www.flatnet.net/

Phil Roberts wrote:

I’ve posted the source code for my dialogue form at
http://www.flatnet.net/ruby/EditUserDialog.rb.html. If anyone could
give me some hints on how to proceed then I would be grateful.

Here’s one shot at it…

First, connect the “Save” button to a method by doing something like:

save_button.connect(SEL_COMMAND, :onCmdSave)

Next, change all of the variables like firstNameField to instance
variables (i.e. @firstNameField).

Then, within the class definition, create a method similar to this:

def onCmdSave(sender, sel, event)
     sql = "insert into customer values('%s','%s',...)"
     db.query(sql % [@firstNameField.getText, 

@lastNameField.getText, …])

    # Close the edit dialog.
    super
end

This is off the top of my head, but I use something very similar in my
database apps and it works fine.

Hope this helps.

Jamey Cribbs

Confidentiality Notice: This email message, including any attachments, is for the sole use of the intended recipient(s) and may contain confidential and/or privileged information. If you are not the intended recipient(s), you are hereby notified that any dissemination, unauthorized review, use, disclosure or distribution of this email and any materials contained in any attachments is prohibited. If you receive this message in error, or are not the intended recipient(s), please immediately notify the sender by email and destroy all copies of the original message, including attachments.

Jamey Cribbs cribbsj@oakwood.org shot from the breach towards
his enemies, screaming forth the battle cry:

This is off the top of my head, but I use something very similar
in my database apps and it works fine.

Hope this helps.

Thank you, and I can figure out how to make the update from this.
Unfortunatly I can’t get the dialogue box to close properly. If I
hit “save” then it resets the parent window (which I don’t want)

Heres a screenshot of the interface as it stands:
http://www.flatnet.net/ruby/rubyadmin_shot.jpg

When I hit cancel it behaves as I want, i.e. it returns to the main
customer listing. However if I hit save it resets the main view
pane to a blank placeholder and doesn’t close the dialogue box.
Instead I have to force the closure by hitting cancel and then
return to the customer listing via the main menu.

Chances are my architecture (such as it is) is completly b0rked.
But as I say, I am a beginner at this. And short of downloading
every FXRuby application I can find I really don’t have much
reference material available. (I tried looking over the source code
for FreeRIDE. But soon wished I hadn’t :wink: as it was totally over
my head)

···


Phil Roberts | Without me its just aweso. | http://www.flatnet.net/

Phil Roberts wrote:

When I hit cancel it behaves as I want, i.e. it returns to the main
customer listing. However if I hit save it resets the main view
pane to a blank placeholder and doesn’t close the dialogue box.
Instead I have to force the closure by hitting cancel and then
return to the customer listing via the main menu.

Try this…

1). Rename the onCmdSave method to onCmdAccept.

2). Make sure you have the command “super” in your onCmdAccept method.

I usually name my method “onCmdAccept”. I think that when I sent you
the example and changed the method name to onCmdSave, what was happening
was that the call to “super” was not invoking the FXDialog’s onCmdAccept
method. It’s probably in this method that the dialog box get’s closed.

I’m shooting from the hip again. It’s been a long time since I had to
figure this part out, so my memory is a little fuzzy! :slight_smile:

Jamey

Confidentiality Notice: This email message, including any attachments, is for the sole use of the intended recipient(s) and may contain confidential and/or privileged information. If you are not the intended recipient(s), you are hereby notified that any dissemination, unauthorized review, use, disclosure or distribution of this email and any materials contained in any attachments is prohibited. If you receive this message in error, or are not the intended recipient(s), please immediately notify the sender by email and destroy all copies of the original message, including attachments.

Jamey Cribbs cribbsj@oakwood.org shot from the breach towards his
enemies, screaming forth the battle cry:

1). Rename the onCmdSave method to onCmdAccept.

Yay! That fixed the closure problem. Now I just need to figure out
why the parent window keeps resetting. Thank you.

···


Phil Roberts | Without me its just aweso. | http://www.flatnet.net/