[fxruby-users] Programmatically closing a dialog box

Thomas, Jason M (Software) jmthomas at ball.com
Wed Dec 19 13:00:07 EST 2007


Philippe and Lyle both suggested the same solution to pushing the button which works perfectly. I did give pseudokeyboard a try but it didn't work for me in this instance because I needed to pass the button as the sender instead of self.

Another thing I needed to do was to close a dialog once it was opened. I tried many things like opening the dialog in a different thread but it seemed like once the dialog was open I could not get access to it to close it. A coworker pointed me to FXApp.addTimeout which worked great. I open the dialog in a different thread and then add the timeout which closes it.

  app = FXApp.instance
  buttons = app.activeWindow.instance_variable_get :@buttons
  dialog = app.activeWindow.instance_variable_get :@dialog_box  
  t = Thread.new do
    # Launch the dialog box
    buttons[0].handle(buttons[0], FXSEL(SEL_LEFTBUTTONPRESS, 0), nil)
    buttons[0].handle(buttons[0], FXSEL(SEL_LEFTBUTTONRELEASE, 0), nil)
    sleep 2
  end
    
  app.addTimeout(1000) do |sender, sel, data|
    dialog.handle(app, MKUINT(FXDialogBox::ID_CANCEL, SEL_COMMAND), nil)
  end

Hope this can help someone else fumbling for a way to do unit testing.

Jason

-----Original Message-----
From: Philippe Lang [mailto:philippe.lang at attiksystem.ch] 
Sent: Wednesday, December 19, 2007 12:20 AM
To: fxruby-users at rubyforge.org
Cc: Thomas, Jason M (Software)
Subject: RE: [fxruby-users] programmatically "pushing" a button

Hi Jason,
 
Can you try this?
 
button.handle(self, FXSEL(SEL_LEFTBUTTONPRESS, 0), nil)
button.handle(self, FXSEL(SEL_LEFTBUTTONRELEASE, 0), nil)


It would be a good idea to have a look at these classes too:
 
pseudokeyboard.rb
pseudomouse.rb
 
(You might find them here, more or less: C:\ruby\lib\ruby\gems\1.8\gems\fxruby-1.6.13-mswin32\lib\fox16)
 
I think it does exactly what you need.
 
Regards,

Philippe Lang

________________________________

De : fxruby-users-bounces at rubyforge.org [mailto:fxruby-users-bounces at rubyforge.org] De la part de Thomas, Jason M (Software) Envoyé : mardi, 18. décembre 2007 20:09 À : fxruby-users at rubyforge.org Objet : [fxruby-users] programmatically "pushing" a button


I'm trying to use the Ruby unit test framework to exercise my FxRuby application. I have access to my button but I don't know how to programmatically "push" it. I tried the following:
 
  button.handle(button, MKUINT(FXWindow::ID_ENABLE, SEL_COMMAND), nil)
 
This appears to have no effect at all. What am I doing wrong?
 
Jason


This message and any enclosures are intended only for the addressee.  Please notify the sender by email if you are not the intended recipient.  If you are not the intended recipient, you may not use, copy, disclose, or distribute this message or its contents or enclosures to any other person and any such actions may be unlawful.  Ball reserves the right to monitor and review all messages and enclosures sent to or from this email address.




This message and any enclosures are intended only for the addressee.  Please  
notify the sender by email if you are not the intended recipient.  If you are  
not the intended recipient, you may not use, copy, disclose, or distribute this  
message or its contents or enclosures to any other person and any such actions  
may be unlawful.  Ball reserves the right to monitor and review all messages  
and enclosures sent to or from this email address.


More information about the fxruby-users mailing list