On Tue, 26 Jul 2005 15:32:41 -0400, Bill Atkins <batkins57@gmail.com> wrote :> With fxruby gem 1.2.6 and ruby 1.8.2 Windows, running this code: > > -- > > require_gem ''fxruby'' > include Fox > > app = FXApp.new > win = FXMainWindow.new app, "Test" > > FXTreeList.new win, 0 > > app.create > app.run > > -- > > produces > > C:\development\simulation>ruby bug_report.rb > bug_report.rb:7:in `initialize'': wrong argument type Fixnum (expected Data) > (Typ > eError) > from bug_report.rb:7:in `new'' > from bug_report.rb:7 > > Why does this happen? The second argument should be an integer representing > the number of visible items. In the example code on > fxruby.org<http://fxruby.org>, > FXTreeList.new is called with an integer for its second parameter. > > Is this a bug or am I doing something wrong?The documentation is wrong; the "nvis" argument (which used to be the second argument) is no longer there. I''ve just added a bug report about this.
I''m experiencing an interesting issue with FXRuby 1.2.6 on Windows. I have the following code: self.accelTable.addAccel(fxparseAccel("Ctrl-F4"), self, FXSEL(SEL_COMMAND, FXApp::ID_LAST+124)) FXMAPFUNC(SEL_COMMAND, FXApp::ID_LAST+124, :do_close_file) Then later: def do_close_file(sender, sel, ptr) puts(sender); puts(sel); puts(ptr); end This code always crashes with a segementation fault at puts(ptr); I believe ptr should contain the ID of the message (FXApp::ID_LAST+124). Also, as long as I''m here... Is there a ''quicker'' or cleaner way to map a function to the accelerator table than what I did above? I couldn''t any examples on how to do it and really just cobbled that together from a hint a saw on a blog somewhere. Roy
Roy Sutton wrote:> I''m experiencing an interesting issue with FXRuby 1.2.6 on Windows. I > have the following code: > > self.accelTable.addAccel(fxparseAccel("Ctrl-F4"), self, > FXSEL(SEL_COMMAND, FXApp::ID_LAST+124)) > FXMAPFUNC(SEL_COMMAND, FXApp::ID_LAST+124, > :do_close_file) > > Then later: > > def do_close_file(sender, sel, ptr) > puts(sender); > puts(sel); > puts(ptr); > end > > This code always crashes with a segementation fault at puts(ptr); I > believe ptr should contain the ID of the message (FXApp::ID_LAST+124). >Roy, this won''t help much, but I had a very similar problem using addAccel. I don''t remember the details, but a few months ago I was working on a fairly complex app. I had a lot of the menu items mapped to the accelTable using addAccel. Well, I remember that my app started crashing with a seg fault. I was able to trace it to the accelTable. I tried everything I could to track down the problem. I finally narrowed it down to, I think, a problem where Ruby''s garbage collector was prematurely collecting one of my references. I can''t really remember more than that. I ended up removing all of the addAccel code and figured out a different way to add hotkey support (I think I ended up trapping for the actual key codes). Sorry for the vagueness, the old memory cells go fast at my age. :-) Jamey Cribbs
Jamey, Thanks for the info. Any chance you can remember how you trapped the key codes? Roy Jamey Cribbs wrote:> I ended up removing all of the addAccel code and figured out a > different way to add hotkey support (I think I ended up trapping for > the actual key codes).
Hi, Roy. To trap keyboard you can to c-tor (initialize) mapping: FXMAPFUNC(SEL_KEYPRESS, 0,"handleKeyPressed") And the implementation can be something like this: def handleKeyPressed keyvalue = 97 # a keystate = 8 # Alt if ( ptr.code == keyvalue and ptr.state == keystate ) #handle event elsif (ptr.code == ... ... end end Regards, Alex. -----Original Message----- From: fxruby-users-bounces@rubyforge.org [mailto:fxruby-users-bounces@rubyforge.org] On Behalf Of Roy Sutton Sent: Wednesday, July 27, 2005 6:17 AM To: fxruby-users@rubyforge.org Subject: Re: [fxruby-users] Issue with callback Jamey, Thanks for the info. Any chance you can remember how you trapped the key codes? Roy Jamey Cribbs wrote:> I ended up removing all of the addAccel code and figured out a > different way to add hotkey support (I think I ended up trapping for > the actual key codes)._______________________________________________ fxruby-users mailing list fxruby-users@rubyforge.org http://rubyforge.org/mailman/listinfo/fxruby-users
Thank you! This will be a better solution anyhow. Panich, Alexander wrote:>Hi, Roy. > >To trap keyboard you can to c-tor (initialize) mapping: > FXMAPFUNC(SEL_KEYPRESS, 0,"handleKeyPressed") > >And the implementation can be something like this: > >def handleKeyPressed > keyvalue = 97 # a > keystate = 8 # Alt > if ( ptr.code == keyvalue and ptr.state == keystate ) > #handle event > elsif (ptr.code == ... > ... > end >end > >Regards, >Alex. > > >-----Original Message----- >From: fxruby-users-bounces@rubyforge.org >[mailto:fxruby-users-bounces@rubyforge.org] On Behalf Of Roy Sutton >Sent: Wednesday, July 27, 2005 6:17 AM >To: fxruby-users@rubyforge.org >Subject: Re: [fxruby-users] Issue with callback > >Jamey, > >Thanks for the info. Any chance you can remember how you trapped the >key codes? > >Roy > >Jamey Cribbs wrote: > > > >>I ended up removing all of the addAccel code and figured out a >>different way to add hotkey support (I think I ended up trapping for >>the actual key codes). >> >> > > >_______________________________________________ >fxruby-users mailing list >fxruby-users@rubyforge.org >http://rubyforge.org/mailman/listinfo/fxruby-users > >_______________________________________________ >fxruby-users mailing list >fxruby-users@rubyforge.org >http://rubyforge.org/mailman/listinfo/fxruby-users > > > > >