FXRuby - handling Alt+F4

C

Chris Morris

I'm trying to properly write a way to capture an Alt+F4 keystroke, and
I'm not finding the right constant for the Alt key. Here's what I've
currently got, and it works, but obviously isn't the 'correct' way to
&& out the Alt key from the evt.state:

if (evt.state == 24) && (evt.code == KEY_F4)
exit
else
...
end
 
S

Stephan Kämper

Chris said:
I'm trying to properly write a way to capture an Alt+F4 keystroke, and
I'm not finding the right constant for the Alt key. Here's what I've
currently got, and it works, but obviously isn't the 'correct' way to
&& out the Alt key from the evt.state:

if (evt.state == 24) && (evt.code == KEY_F4)
exit
else
...
end

I did it by writing this:

menu_bar = FXMenubar.new( self, LAYOUT_SIDE_TOP | LAYOUT_FILL_X )

file_menu = FXMenuPane.new( self )
FXMenuCommand.new( fileMenu, "&Quit\tALT-F4", nil, app, FXApp::ID_QUIT )

I'm sure there are ways to close an application without having a menu
bar. Lyle?

Happy rubying

Stephan
 
L

Lyle Johnson

On Tue, 8 Feb 2005 04:25:12 +0900, Stephan Kämper
I'm sure there are ways to close an application without having a menu
bar. Lyle?

I haven't tried this, but what happens if you just add the accelerator
directly to the main window's accelerator table, i.e.

mainWindow.addAccel(fxparseAccel("Alt+F4"), app, FXApp::ID_QUIT))

Hope this helps,

Lyle
 
L

Lyle Johnson

fxparseAccel failed -- not in scope or what-have-you -- what requires
do I need to be able to use this? (Or is it a version problem? Not
sure what version I'm using).

I think you must be using FXRuby 1.0, and I was using the FXRuby 1.2
"spelling". Try "fxparseaccel" (with all lowercase letters) instead.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,169
Messages
2,570,915
Members
47,456
Latest member
JavierWalp

Latest Threads

Top