Thomas, Jason M (Software)
2007-Dec-18 19:08 UTC
[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. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/fxruby-users/attachments/20071218/818938b1/attachment.html
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.
On Dec 18, 2007, at 1:08 PM, Thomas, Jason M ((Software)) wrote:> 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?SEL_COMMAND is a message that the button sends to its target after the user presses, then releases the left mouse button. In the code you posted, you''re sending a SEL_COMMAND message to the button, with the ID_ENABLE message identifier, which just tells the button to enable itself. It''s a valid message to send to the button, but it''s not going to accomplish what you''re after. I haven''t tried this, but I suppose you could simulate a button press and release by sending a SEL_LEFTBUTTONPRESS message to the button, followed by a SEL_LEFTBUTTONRELEASE message, e.g. button.handle(nil, FXSEL(SEL_LEFTBUTTONPRESS, 0), nil) button.handle(nil, FXSEL(SEL_LEFTBUTTONRELEASE, 0), nil) In theory, that ought to then cause the button to fire off its SEL_COMMAND message, just as if someone had pressed and released the button. Hope this helps, Lyle -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/fxruby-users/attachments/20071219/303a71aa/attachment.html
Thomas, Jason M (Software)
2007-Dec-19 18:00 UTC
[fxruby-users] Programmatically closing a dialog box
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.
Melton, Ryan
2008-Jan-10 18:58 UTC
[fxruby-users] SEL_MAXIMIZE, SEL_MINIMIZE, and SEL_RESTORE not working for FXMainWindow
Hi, I am running on Windows XP SP2 using FXRuby 1.6.11 which uses FOX version 1.6.25. The SEL_MAXIMIZE, SEL_MINIMIZE, and SEL_RESTORE handlers do not seem to ever get called for an FXMainWindow. Can anyone else recreate this? Here is a simple example program: The SEL_CLOSE works but none of the other handlers. $VERBOSE = nil require ''fox16'' $VERBOSE = true include Fox class Test < FXMainWindow def initialize(app) super(app, "Test", nil, nil, DECOR_ALL, 0, 0, 750, 500) self.connect(SEL_CLOSE) do |sender, sel, data| puts "CLOSE" 0 end self.connect(SEL_MAXIMIZE) do |sender, sel, data| puts "MAXIMIZE" 0 end self.connect(SEL_RESTORE) do |sender, sel, data| puts "RESTORE" 0 end self.connect(SEL_MINIMIZE) do |sender, sel, data| puts "MINIMIZE" 0 end end def create super show(PLACEMENT_SCREEN) end end application = FXApp.new("Test", "Test") Test.new(application) application.create application.run Thanks, Ryan 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.
Jeroen van der Zijp
2008-Jan-10 19:11 UTC
[fxruby-users] [Foxgui-users] SEL_MAXIMIZE, SEL_MINIMIZE, and SEL_RESTORE not working for FXMainWindow
On Thursday 10 January 2008 12:58:34 pm Melton, Ryan wrote:> Hi, > > I am running on Windows XP SP2 using FXRuby 1.6.11 which uses FOX > version 1.6.25. > > The SEL_MAXIMIZE, SEL_MINIMIZE, and SEL_RESTORE handlers do not seem to > ever get called for an FXMainWindow. > > Can anyone else recreate this? Here is a simple example program: The > SEL_CLOSE works but none of the other handlers. > > > $VERBOSE = nil > require ''fox16'' > $VERBOSE = true > > include Fox > > class Test < FXMainWindow > > def initialize(app) > super(app, "Test", nil, nil, DECOR_ALL, 0, 0, 750, 500) > > self.connect(SEL_CLOSE) do |sender, sel, data| > puts "CLOSE" > 0 > end > > self.connect(SEL_MAXIMIZE) do |sender, sel, data| > puts "MAXIMIZE" > 0 > end > > self.connect(SEL_RESTORE) do |sender, sel, data| > puts "RESTORE" > 0 > end > > self.connect(SEL_MINIMIZE) do |sender, sel, data| > puts "MINIMIZE" > 0 > end > end > > def create > super > show(PLACEMENT_SCREEN) > end > end > > application = FXApp.new("Test", "Test") > Test.new(application) > application.create > application.runThe messages are generated when notify=true is passed when these maximize(), minimize() [etc] are called. When its done by the user, you just get SEL_CONFIGURE messages. Note that if you need to find out minimized, maximized state, you can call the isMaximized() and isMinimized() API''s. They should give the correct answer even if maximization was done by the user rather than programmatically. Hope this helps, Jeroen
Melton, Ryan
2008-Jan-10 19:27 UTC
[fxruby-users] [Foxgui-users] SEL_MAXIMIZE, SEL_MINIMIZE, and SEL_RESTORE not working for FXMainWindow
Thanks Jeroen, Using the SEL_CONFIGURE I can detect maximizes and minimizes. What I wanted to do was to not let a user maximize the window sometimes. Can I do this with SEL_CONFIGURE? -----Original Message----- From: Jeroen van der Zijp [mailto:jeroen at fox-toolkit.org] Sent: Thursday, January 10, 2008 12:12 PM To: foxgui-users at lists.sourceforge.net Cc: Melton, Ryan; fxruby-users at rubyforge.org Subject: Re: [Foxgui-users] SEL_MAXIMIZE, SEL_MINIMIZE, and SEL_RESTORE not working for FXMainWindow On Thursday 10 January 2008 12:58:34 pm Melton, Ryan wrote:> Hi, > > I am running on Windows XP SP2 using FXRuby 1.6.11 which uses FOX > version 1.6.25. > > The SEL_MAXIMIZE, SEL_MINIMIZE, and SEL_RESTORE handlers do not seemto> ever get called for an FXMainWindow. > > Can anyone else recreate this? Here is a simple example program: The > SEL_CLOSE works but none of the other handlers. > > > $VERBOSE = nil > require ''fox16'' > $VERBOSE = true > > include Fox > > class Test < FXMainWindow > > def initialize(app) > super(app, "Test", nil, nil, DECOR_ALL, 0, 0, 750, 500) > > self.connect(SEL_CLOSE) do |sender, sel, data| > puts "CLOSE" > 0 > end > > self.connect(SEL_MAXIMIZE) do |sender, sel, data| > puts "MAXIMIZE" > 0 > end > > self.connect(SEL_RESTORE) do |sender, sel, data| > puts "RESTORE" > 0 > end > > self.connect(SEL_MINIMIZE) do |sender, sel, data| > puts "MINIMIZE" > 0 > end > end > > def create > super > show(PLACEMENT_SCREEN) > end > end > > application = FXApp.new("Test", "Test") > Test.new(application) > application.create > application.runThe messages are generated when notify=true is passed when these maximize(), minimize() [etc] are called. When its done by the user, you just get SEL_CONFIGURE messages. Note that if you need to find out minimized, maximized state, you can call the isMaximized() and isMinimized() API''s. They should give the correct answer even if maximization was done by the user rather than programmatically. Hope this helps, Jeroen 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.
Jeroen van der Zijp
2008-Jan-10 19:45 UTC
[fxruby-users] [Foxgui-users] SEL_MAXIMIZE, SEL_MINIMIZE, and SEL_RESTORE not working for FXMainWindow
On Thursday 10 January 2008 01:27:48 pm Melton, Ryan wrote:> Thanks Jeroen, > > Using the SEL_CONFIGURE I can detect maximizes and minimizes. What I > wanted to do was to not let a user maximize the window sometimes. Can I > do this with SEL_CONFIGURE?Typically, this is done by adjusting the decorations. Once you''ve decided to show the [lets say] maximize button, it''ll get handled. There''s no way to block it since the event is dealt with in the non-client handler of the window. FOX itself never sees it. On X11, its the same way since the decorations and maximization is done by the window-manager. All we get is a notify when its done. So, long story short: just change DECOR_XXX options; you may need to play around a bit with the options since some of them are coupled. Hope this helps, - Jeroen
Jeroen van der Zijp
2008-Jan-10 21:20 UTC
[fxruby-users] [Foxgui-users] SEL_MAXIMIZE, SEL_MINIMIZE, and SEL_RESTORE not working for FXMainWindow
On Thursday 10 January 2008 03:03:39 pm Sander Jansen wrote:> Ok, h > > On Jan 10, 2008 1:45 PM, Jeroen van der Zijp <jeroen at fox-toolkit.org> wrote: > > On Thursday 10 January 2008 01:27:48 pm Melton, Ryan wrote: > > > Thanks Jeroen, > > > > > > Using the SEL_CONFIGURE I can detect maximizes and minimizes. What I > > > wanted to do was to not let a user maximize the window sometimes. Can I > > > do this with SEL_CONFIGURE? > > > > Typically, this is done by adjusting the decorations. Once you''ve decided > > to show the [lets say] maximize button, it''ll get handled. There''s no way > > to block it since the event is dealt with in the non-client handler of the > > window. FOX itself never sees it. > > Well, that''s not totally true, just because you''re ignoring the > message, doesn''t mean you don''t get it.. > > How about sending SEL_MAXIMIZE, SEL_MINIMIZE, SEL_RESTORE based on > information from the WM_SIZE message on windows: > > See the WM_SIZE documentation: > http://msdn2.microsoft.com/en-us/library/ms632646.aspx. It tells you > exactly what happened. > > On Linux you can do the same thing whenever the _NET_STATE changes... > > On Windows you can also intercept the maximize/minimize/restore event > s before they''re applied using the WM_SYSCOMMAND message: > > See documentation here: http://msdn2.microsoft.com/en-us/library/ms646360.aspxIt sounds like a good idea to try and intercept the messages; but you wouldn''t necessarily be able to block the maximization or minimization this way. But at least you''d know about it when it happens. - Jeroen