Dietmar Schwertberger
unread,Jan 24, 2024, 2:02:28 PM1/24/24Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Nathan smith, wxpytho...@googlegroups.com
Hi Nathan,
when I wrote "code sample", I meant a sample that's actually runnable to
show the problem.
But from the snippets I could see that the menus are not shown a the
same time. That helped.
I have create a small sample of a frame with a menu, a panel and either
a text or a grid control or both.
The samples actually behave different in the way that you described.
I have also checked two C++ samples from the wxWidgets repository and
they show the same difference.
The menu bars get activated in both cases. I can see that the menu
access keys are underlined after the first Alt key press.
But when the grid has the focus, no further keys presses seem to be sent
to the menu bar, so I can't navigate. So, for example, even when I press
Escape, the underlines do remain.
I will check whether I can fix the wxWidgets bug, but it takes time
until a fix propagates into wxPython.
As workaround, I have bound EVT_CHAR_HOOK and that can catch the ALT key
for the grid.
Unfortunately, I don't see a quick way to transfer the focus to the MenuBar.
It's possible to set focus to the frame from the event handler and this
will then trigger the menu.
But when you close the menu, the focus will not be transfered back to
the grid automatically.
Maybe it would be possible to handle an event when the menu is closed
and then set the focus again.
These are the code snippets:
self.grid_1.Bind(wx.EVT_CHAR_HOOK, self.evt_char_hook_grid)
def evt_char_hook_grid(self, event):
if event.GetKeyCode()==wx.WXK_ALT and event.GetModifiers()==wx.MOD_ALT:
self.frame_menubar.GetParent().SetFocus()
event.Skip()
Regards,
Dietmar