Paul Carvalho
2010-Mar-31 05:13 UTC
[fxruby-users] Need help getting ALT+F4 hotkey to work
Hi there, quick question. I am trying to make my app aware of the ALT+F4 hot-key to quit but can''t quite get the syntax correct. My app has a method to handle the close/quit event, and I have the following lines: ---- button_quit.connect(SEL_COMMAND, method( :onCmdQuit )) self.connect(SEL_CLOSE, method( :onCmdQuit )) # self.accelTable.addAccel( fxparseAccel( "Alt+F4" ), self, method( :onCmdQuit ) ) ---- The first 2 lines work as expected and re-route the Quit event from either the ''Quit'' button or the [X] close button from the title bar to the shutdown method. (good) The 3rd line doesn''t work though. When I run the app, I get the error: "in `addAccel'': can''t convert Method into Integer (TypeError)" What am I missing? I''ve tried several variations on that command to get the hot-key to work but I''ve had no luck yet. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/fxruby-users/attachments/20100331/28f5a23e/attachment-0001.html>
Bartosz DziewoĆski
2010-Mar-31 11:12 UTC
[fxruby-users] Need help getting ALT+F4 hotkey to work
http://www.fxruby.org/doc/api/classes/Fox/FXAccelTable.html#M000142 You probably (I didn''t test it) need to send SEL_CLOSE command to your main window in third line (and then it will be catched by your second line), using technique mentioned under that link. Read docs, they contain lots of info. -- Matma Rex - http://matma-rex.prv.pl/
Paul Carvalho
2010-Mar-31 15:03 UTC
[fxruby-users] Need help getting ALT+F4 hotkey to work
2010/3/31 Bartosz Dziewo?ski <matma.rex at gmail.com>> http://www.fxruby.org/doc/api/classes/Fox/FXAccelTable.html#M000142 > > You probably (I didn''t test it) need to send SEL_CLOSE command to your > main window in third line (and then it will be catched by your second > line), using technique mentioned under that link. > > Read docs, they contain lots of info. > >I read the docs before I posted my question. They do contain lots of info but nothing that helped me. Can you provide an example to help me understand what you''re suggesting? I don''t know how to that. Thanks. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/fxruby-users/attachments/20100331/aff5ea54/attachment.html>
On Wed, Mar 31, 2010 at 10:03 AM, Paul Carvalho <tester.paul at gmail.com> wrote:> I read the docs before I posted my question. ?They do contain lots of info > but nothing that helped me. > Can you provide an example to help me understand what you''re suggesting? I > don''t know how to that.What happens if you replace the third line with this: self.accelTable.addAccel( fxparseAccel( "Alt+F4" ), self, FXSEL(SEL_CLOSE, 0) ) ?
Paul Carvalho
2010-Mar-31 16:11 UTC
[fxruby-users] Need help getting ALT+F4 hotkey to work
Aha! You da man! Who da man? You da man! =) Thanks Lyle. That works perfectly. Cheers! On 31 March 2010 11:46, Lyle Johnson wrote:> > What happens if you replace the third line with this: > > self.accelTable.addAccel( fxparseAccel( "Alt+F4" ), self, > FXSEL(SEL_CLOSE, 0) ) > > ? >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/fxruby-users/attachments/20100331/dbb3f596/attachment.html>