Code::Blocks Forums

User forums => Help => Topic started by: schickb on April 25, 2008, 08:07:50 pm

Title: Mapping F10 key doesn't work
Post by: schickb on April 25, 2008, 08:07:50 pm
I am using CB on Ubuntu 8.04 32bit. Mapping keyboard shortcuts to the F keys work for all that I have tried except the F10 key. When I assign that to something (like "next line"), and then hit the F10 key the File menu opens up. Anyone else seen this? I don't think F10 is a special key for gnome.
Title: Re: Mapping F10 key doesn't work
Post by: eranif on April 25, 2008, 10:32:48 pm
Hi,

I assume that you are trying to map keys to fit the visual studio schema  :wink:

I encoutered this bug in the past in my application, and I ended up adding the following hack in the code:

Code
//add include file required for the hack
#ifdef __WXGTK20__
#include <gtk-2.0/gtk/gtk.h>
#endif

//add this code somewhere in the frame constructor
#if  defined(__WXGTK20__)
// A rather ugly hack here.  GTK V2 insists that F10 should be the
// accelerator for the menu bar.  We don't want that.  There is
// no sane way to turn this off, but we *can* get the same effect
// by setting the "menu bar accelerator" property to the name of a
// function key that is apparently legal, but doesn't really exist.
// (Or if it does, it certainly isn't a key we use.)
gtk_settings_set_string_property (gtk_settings_get_default (),
                                  "gtk-menu-bar-accel", "F15", "foo");

#endif

You will also need to update your makefile accordingly:
add to the include path:
Code
pkg-config --cflags gtk+-2.0

and to the lib path:
Code
pkg-config --libs gtk+-2.0

Works like a charm :)
Eran
Title: Re: Mapping F10 key doesn't work
Post by: schickb on April 25, 2008, 11:12:51 pm
Thanks, I'll give it a try. Or maybe I'll have to retrain the fingers at some point.
Title: Re: Mapping F10 key doesn't work
Post by: chrisstankevitz on August 31, 2009, 05:10:05 am
You will also need to update your makefile accordingly:
add to the include path:
Code
pkg-config --cflags gtk+-2.0

Hello,

I'm new to makefiles.  Can you tell me how to do this step for the CB configure.in file?  I would like to apply this hack to CB.

Thank you,

Chris
Title: Re: Mapping F10 key doesn't work
Post by: yaoyansi on September 02, 2014, 07:28:11 am
Hi,

I assume that you are trying to map keys to fit the visual studio schema  :wink:

I encoutered this bug in the past in my application, and I ended up adding the following hack in the code:

Code
//add include file required for the hack
#ifdef __WXGTK20__
#include <gtk-2.0/gtk/gtk.h>
#endif

//add this code somewhere in the frame constructor
#if  defined(__WXGTK20__)
// A rather ugly hack here.  GTK V2 insists that F10 should be the
// accelerator for the menu bar.  We don't want that.  There is
// no sane way to turn this off, but we *can* get the same effect
// by setting the "menu bar accelerator" property to the name of a
// function key that is apparently legal, but doesn't really exist.
// (Or if it does, it certainly isn't a key we use.)
gtk_settings_set_string_property (gtk_settings_get_default (),
                                  "gtk-menu-bar-accel", "F15", "foo");

#endif

You will also need to update your makefile accordingly:
add to the include path:
Code
pkg-config --cflags gtk+-2.0

and to the lib path:
Code
pkg-config --libs gtk+-2.0

Works like a charm :)
Eran


Thanks for your solution. But I'm using the binary installer.
Will this hack code be integrated into C::B?
Title: Re: Mapping F10 key doesn't work
Post by: oBFusCATed on September 02, 2014, 11:49:08 pm
I don't think so...