Discussion:
Event propagation
(too old to reply)
Guillaume GOURDIN
2009-04-30 16:22:20 UTC
Permalink
Hi,

I have a application with a main wxFrame with a menu and a child
floating wxFrame. I would like the menu shortcus of the menu to be
processed from the child window too, but it does not seem to be the
case, event though I can read, in the events doc, that "the events do
propagate beyond the frames, however".

I tried to set to the child frame the accelarator table of the parent,
but it does not work either.

Anyone has a clue?

Thank you.

- Guillaume -
Ronny Krueger
2009-04-30 16:49:11 UTC
Permalink
Post by Guillaume GOURDIN
Hi,
I have a application with a main wxFrame with a menu and a child
floating wxFrame. I would like the menu shortcus of the menu to be
processed from the child window too, but it does not seem to be the
case, event though I can read, in the events doc, that "the events do
propagate beyond the frames, however".
I tried to set to the child frame the accelarator table of the parent,
but it does not work either.
Anyone has a clue?
You have to set the accelerator table of your menu bar for the floating
frame. In my application I do it like this:

wxMenuBar* menuBar = mainFrame->GetMenuBar();
if(menuBar)
{
wxAcceleratorTable* accelTable = menuBar->GetAcceleratorTable();
if(accelTable && accelTable->IsOk())
floatingFrame->SetAcceleratorTable(*accelTable);
}

There was a bug in wx which prevented this code from working, but it has
been fixed some time ago. So if this code does not work for you your
wxwidgets version might just be too old.

Best regards,

Ronny
Vadim Zeitlin
2009-05-01 10:18:51 UTC
Permalink
On Thu, 30 Apr 2009 18:22:20 +0200 Guillaume GOURDIN <***@hotmail.com> wrote:

GG> I have a application with a main wxFrame with a menu and a child
GG> floating wxFrame. I would like the menu shortcus of the menu to be
GG> processed from the child window too, but it does not seem to be the
GG> case, event though I can read, in the events doc, that "the events do
GG> propagate beyond the frames, however".

Yes, they indeed should. Are you sure you specified the main frame as
parent for the other one? If you think you did everything correctly and
still don't get any events then you should try to reproduce the problem in
the minimal sample.

GG> I tried to set to the child frame the accelarator table of the parent,
GG> but it does not work either.

This should work too. And using Connect() to connect child frame menu
events to the handlers in the parent will work as well.

Regards,
VZ
--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/
Continue reading on narkive:
Loading...