From: Vadim Zeitlin Date: Sun, 5 Feb 2006 23:50:13 +0000 (+0000) Subject: now we don't only show label mnemonics but they also work X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/259858fc6a55dd1f611dbec323264fdbad8b44fb now we don't only show label mnemonics but they also work git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@37345 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index fa4e690b3b..43673380dc 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -47,6 +47,7 @@ #include "wx/settings.h" #include "wx/log.h" #include "wx/fontutil.h" +#include "wx/stattext.h" #ifdef __WXDEBUG__ #include "wx/thread.h" @@ -3542,13 +3543,40 @@ void wxWindowGTK::RealizeTabOrder() { if ( !m_children.empty() ) { +#if wxUSE_STATTEXT + // we don't only construct the correct focus chain but also use + // this opportunity to update the mnemonic widgets for all labels + // + // it would be nice to extract this code from here and put it in + // stattext.cpp to reduce dependencies but there is no really easy + // way to do it unfortunately + wxStaticText *lastLabel = NULL; +#endif // wxUSE_STATTEXT + GList *chain = NULL; for ( wxWindowList::const_iterator i = m_children.begin(); i != m_children.end(); ++i ) { - chain = g_list_prepend(chain, (*i)->m_widget); + wxWindowGTK *win = *i; +#if wxUSE_STATTEXT + if ( lastLabel ) + { + if ( win->AcceptsFocusFromKeyboard() ) + { + GtkLabel *l = GTK_LABEL(lastLabel->m_widget); + gtk_label_set_mnemonic_widget(l, win->m_widget); + lastLabel = NULL; + } + } + else // check if this one is a label + { + lastLabel = wxDynamicCast(win, wxStaticText); + } +#endif // wxUSE_STATTEXT + + chain = g_list_prepend(chain, win->m_widget); } chain = g_list_reverse(chain);