gtk menu accelerators

gtk menu accelerators

Post by James Gardin » Tue, 09 Jun 1998 04:00:00



I recently posted this under an unreplyable address (Hey!  A SLRN newbie!!)
and am giving this another chance to be replied to under a *real* address!
 :)

At the risk of sounding like the gtk newbie that I am, I wonder if anybody
else has had problems with the "auto-accelerators" that gtk installs on the
menus?

I mean, when you install the menu (or menubar) and the menuitems, whether or
not you use a menufactory, you get installable accelerators from the get-go.
While this may be thought of a feature and not a bug, it has an interesting
side-effect for a new or even casual user of an app developed with gtk.

The user mouses onto the menu and clicks it.  He accidentally presses space on
his keyboard instead of hitting the mouse button.  This installs the space bar
as the accelerator for that menu function automagically.  Then Joe User is
merrily working away and accidentally presses the space bar again.  This
activates the carelessly installed accelerator.

Now the user didn't mean to do all this.  He or she may not even be aware that
the gtk-based app that was just downloaded or purchased contains these
creatures.  But after two hours of working hard to finish the budget
spreadsheet or the Great American Novel a seemingly innocent touch of the
space bar can activate a quit or delete function on a menu.

Now I realize that a good developer can safeguard the user from himself most
of the time, I just think that there HAS to be a way to deactivate the
auto-accelerator creation without deactivating the menus or the keyboard.

Has anybody found the workaround for this? Or am I being overly melodramatic?
Have I gone off the deep end on a simple function call?  I really like gtk's
overall setup, but Man I wish I had better documentation.  I am working on
the documentation for my personal use (not ready for prime time), but I also
am using gtk for development and to facilitate the accurate documentation of
the various functions within this toolkit.

I haven't reported this to the buglist because I don't know if it's a bug or a
feature.  And I don't know if it can be deactivated.  If anybody has a reply
to this problem either post here (extremely helpful to all involved) or send
it to me at my posting address.

Flames will be quietly ignored.

 
 
 

gtk menu accelerators

Post by James Gardin » Thu, 11 Jun 1998 04:00:00


I thought I'd post my own findings after a few days of digging and
experimenting with the gtk source (yet *another* reason to ignore MS stuff for
the freedom of Linux!).

It seems that in gtkmenu.c there is a routine to add accelerators at the touch
of a key.  It is linked into the class through the key_press_event handler and
is a class function (method?).

Therefore, for a menu named menu1 you could disable the auto-accelerators by:

GTK_WIDGET_CLASS(GTK_OBJECT(menu1)->klass)->key_press_event = NULL;

Now you would probably want to save the contents of the function pointer
before NULLing it so you could restore it under controlled circumstances.

I just wanted to thank the gtk people who gave us such great source code to
facilitate understanding how to program their toolkit (and we have to!).  A
great amount of thought obviously has gone into the OO design of gtk.

 
 
 

1. gtk menu accelerators

At the risk of sounding like the gtk newbie that I am, I wonder if anybody
else has had problems with the "auto-accelerators" that gtk installs on the
menus?

I mean, when you install the menu (or menubar) and the menuitems, whether or
not you use a menufactory, you get installable accelerators from the get-go.
While this may be thought of a feature and not a bug, it has an interesting
side-effect for a new or even casual user of an app developed with gtk.

The user mouses onto the menu and clicks it.  He accidentally presses space on
his keyboard instead of hitting the mouse button.  This installs the space bar
as the accelerator for that menu function automagically.  Then Joe User is
merrily working away and accidentally presses the space bar again.  This
activates the carelessly installed accelerator.

Now the user didn't mean to do all this.  He or she may not even be aware that
the gtk-based app that was just downloaded or purchased contains these
creatures.  But after two hours of working hard to finish the budget
spreadsheet or the Great American Novel a seemingly innocent touch of the
space bar can activate a quit or delete function on a menu.

Now I realize that a good developer can safeguard the user from himself most
of the time, I just think that there HAS to be a way to deactivate the
auto-accelerator creation without deactivating the menus or the keyboard.

Has anybody found the workaround for this? Or am I being overly melodramatic?
Have I gone off the deep end on a simple function call?  I really like gtk's
overall setup, but Man I wish I had better documentation.  I am working on
the documentation for my personal use (not ready for prime time), but I also
am using gtk for development and to facilitate the accurate documentation of
the various functions within this toolkit.

I haven't reported this to the buglist because I don't know if it's a bug or a
feature.  And I don't know if it can be deactivated.  If anybody has a reply
to this problem either post here (extremely helpful to all involved) or send
it to me at my posting address.

Flames will be quietly ignored.

2. Panic after install/patching on AXmp+ system

3. GTK Menu Accelerators Examples?

4. Sony SDT-7000 DDS2 problem

5. gtk+-1.0.4 menu accelerators

6. Can not view certain web sites

7. nedit menu accelerators

8. Checking quotas

9. disabeling menu accelerators in solaris 2.2

10. Mootiff Menu Accelerators

11. menu item as destination for drag data (gtk)

12. GNOME/GTK application fonts not working for menu items and other widgets

13. gtk+ option Menus - help!