Re: accelerator keys for (right-click) menu only work after menu has been through a show-all



So Martin Horauer pointed out the solution to me, in private mail ----
thanks Martin!!

I'm recounting his solution here in case somebody else hits this
problem and is searching the net for something and gets to this
thread.

He gave me a link to a site
http://zetcode.com/gui/gtk2/menusandtoolbars/
which has an example popupmenu.c.

There are no accelerator keys in popupmenu.c, but as he says, the
example above them has them, so you can just paste in the code.

And it works without doing the right click even an initial time, the
solution being that you have to do a 'show' on the menu item after
creation (which probably deep in the bowels of gtk does something).

And this also worked for me in my little app (written in the d
programming language, using gtkd which is wraps up gtk3 for d).

dan

On Fri, Nov 25, 2016 at 10:53 AM, Dan Hitt <dan hitt gmail com> wrote:
Hi All,

I'm writing a little app, and i put a right click menu in it.

The menu is created early on, but i only show it (do a show-all on it)
when button 3 (right click) is pressed.

The items in the menu have accelerator keys.

The problem is that although the accelerator keys work after the first
show-all, so that i never have to right click again, i do have to
right click at least once.

Before the first right click, the accelerator keys do not work.

The menu is created early on, but i suppose some crucial piece of it
is must be getting some initialization during gtk_widget_show_all().

Is this correct?

And, if so, is there some way to do a show-all on the menu, without
actually showing anything, just to get the menu items initialized
enough that they can be handled with accelerator keys?

TIA for any info!

dan


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]