]> git.saurik.com Git - wxWidgets.git/commitdiff
Fix wxMenu::GetTitle() before the menu is appended to the menu bar.
authorVadim Zeitlin <vadim@wxwidgets.org>
Fri, 30 Aug 2013 23:32:37 +0000 (23:32 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Fri, 30 Aug 2013 23:32:37 +0000 (23:32 +0000)
The mnemonics conversion was not done correctly when the menu title contained
them but the menu hadn't been appended to the menu bar yet.

Closes #15461.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74731 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

docs/changes.txt
include/wx/gtk/menu.h
src/gtk/menu.cpp
tests/menu/menu.cpp

index 243ee67b6f5f749fe22145d601950fccc10d1730..42d0bc5095c1f7edb4c8e956146afc1df42f7f67 100644 (file)
@@ -572,6 +572,10 @@ All (GUI):
 - Set correct cursor when the mouse is over image map links in wxHTML (LukasK).
 - Add wxPropertyGridPageState::GetColumnFullWidth() (Teodor Petrov).
 
+wxGTK:
+
+- Fix wxMenu::GetTitle() before the menu is appended to the bar (David Hart).
+
 wxMSW:
 
 - It is now possible to tab into radio boxes again.
index 629024591af380c10e14f2b5a363819d8b090e84..fec12ba97786b377ee4899e8a148d451859852ca 100644 (file)
@@ -81,7 +81,8 @@ public:
     // Returns the title, with mnemonics translated to wx format
     wxString GetTitle() const;
 
-    // TODO: virtual void SetTitle(const wxString& title);
+    // Sets the title, with mnemonics translated to gtk format
+    virtual void SetTitle(const wxString& title);
 
     // implementation GTK only
     GtkWidget       *m_menu;  // GtkMenu
index 4cf5d7f04e070653e570eacf6e596b6eb87deea6..f5194b89f0223b41eb98bb2737e7365d6fe5bda0 100644 (file)
@@ -317,11 +317,10 @@ void wxMenuBar::GtkAppend(wxMenu* menu, const wxString& title, int pos)
     else
 #endif // wxUSE_LIBHILDON || wxUSE_LIBHILDON2 /!wxUSE_LIBHILDON && !wxUSE_LIBHILDON2
     {
-        const wxString str(wxConvertMnemonicsToGTK(title));
-
         // This doesn't have much effect right now.
-        menu->SetTitle( str );
+        menu->SetTitle( title );
 
+        const wxString str(wxConvertMnemonicsToGTK(title));
         // The "m_owner" is the "menu item"
         menu->m_owner = gtk_menu_item_new_with_mnemonic( wxGTK_CONV( str ) );
 
@@ -504,10 +503,9 @@ void wxMenuBar::SetMenuLabel( size_t pos, const wxString& label )
 
     wxMenu* menu = node->GetData();
 
-    const wxString str(wxConvertMnemonicsToGTK(label));
-
-    menu->SetTitle( str );
+    menu->SetTitle( label );
 
+    const wxString str(wxConvertMnemonicsToGTK(label));
     if (menu->m_owner)
         gtk_label_set_text_with_mnemonic(GTK_LABEL(gtk_bin_get_child(GTK_BIN(menu->m_owner))), wxGTK_CONV(str));
 }
@@ -843,6 +841,11 @@ wxString wxMenu::GetTitle() const
     return wxConvertMnemonicsFromGTK(wxMenuBase::GetTitle());
 }
 
+void wxMenu::SetTitle(const wxString& title)
+{
+    wxMenuBase::SetTitle(wxConvertMnemonicsToGTK(title));
+}
+
 void wxMenu::GtkAppend(wxMenuItem* mitem, int pos)
 {
     GtkWidget *menuItem;
index 6d73518800cf8067a4ab8d1ba482f831a50ad9ba..2f67765771907e787e75fe7451b176d43f90a26d 100644 (file)
@@ -150,6 +150,10 @@ void MenuTestCase::CreateFrame()
 
     subMenu->AppendSubMenu(subsubMenu, "Subsubmen&u", "Test a subsubmenu");
 
+    // Check GetTitle() returns the correct string _before_ appending to the bar
+    fileMenu->SetTitle("&Foo\tCtrl-F");
+    CPPUNIT_ASSERT_EQUAL( "&Foo\tCtrl-F", fileMenu->GetTitle() );
+
     PopulateMenu(fileMenu, "Filemenu item ", itemcount);
 
     fileMenu->Append(MenuTestCase_Foo, "&Foo\tCtrl-F", "Test item to be found");