Re: accelerators for popup menu
- From: Melvin Hadasht <melvin hadasht free fr>
- To: gtk-app-devel-list gnome org
- Subject: Re: accelerators for popup menu
- Date: Sat, 22 Dec 2001 15:18:58 +0100
Hi,
on Sat, 22 Dec 2001 14:26:44 +0100,
Melvin Hadasht <melvin hadasht free fr> wrote:
Hi,
I'm trying to add accelerators to a popup menu (aka context menu, aka
right-click menu) using a gtk_accel_group. I add an accelerator to the
menuitem and attach the accel group to the menu widget: e.g:
{
...
accel = gtk_accel_group_new();
menu = gtk_menu_new();
item = gtk_menu_item_new_with_label("Item1");
gtk_widget_show(item);
gtk_menu_append(GTK_MENU(menu), item);
gtk_signal_connect(GTK_OBJECT(item), "activate",
GTK_SIGNAL_FUNC(callback), NULL);
gtk_accel_group_add(accel, 's', 0, GTK_ACCEL_LOCKED | GTK_ACCEL_VISIBLE,
GTK_OBJECT(item), "activate");
gtk_accel_group_attach(accel, GTK_OBJECT(menu));
...
}
The accelerator work: I open the context menu and when I type 's', the
callback function is called but then the menu remains open and I like it
to close after activation. I don't know of any application that uses
keyboard shortcuts in context menus, so I have no idea how to do it.
Any idea ? Thanks.
Sorry to answer to my question, but it seems that adding a
gtk_menu_shell_deactivate(GTK_MENU_SHELL(widget->parent)) at the end of
the callback function does the job. But it seems to be a hack... isn't
there a better way?
Thanks
Cheers
--
Melvin Hadasht
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]