Minor correction to the wxMenuItem::SetText() patch.
It also works under GTK 1.2. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@33728 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -818,12 +818,13 @@ void wxMenuItem::SetText( const wxString& str )
|
|||||||
oldLabel = wxStripMenuCodes(oldLabel);
|
oldLabel = wxStripMenuCodes(oldLabel);
|
||||||
oldLabel.Replace(wxT("_"), wxT(""));
|
oldLabel.Replace(wxT("_"), wxT(""));
|
||||||
wxString label1 = wxStripMenuCodes(str);
|
wxString label1 = wxStripMenuCodes(str);
|
||||||
// Make sure we can change a hotkey even if the label is unaltered
|
wxString oldhotkey = GetHotKey(); // Store the old hotkey in Ctrl-foo format
|
||||||
wxString oldhotkey = GetHotKey();
|
wxCharBuffer oldbuf = wxGTK_CONV( GetGtkHotKey(*this) ); // and as <control>foo
|
||||||
|
|
||||||
DoSetText(str);
|
DoSetText(str);
|
||||||
|
|
||||||
if (oldLabel == label1 && oldhotkey == GetHotKey())
|
if (oldLabel == label1 &&
|
||||||
|
oldhotkey == GetHotKey()) // Make sure we can change a hotkey even if the label is unaltered
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (m_menuItem)
|
if (m_menuItem)
|
||||||
@@ -846,10 +847,8 @@ void wxMenuItem::SetText( const wxString& str )
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __WXGTK20__
|
|
||||||
guint accel_key;
|
guint accel_key;
|
||||||
GdkModifierType accel_mods;
|
GdkModifierType accel_mods;
|
||||||
wxCharBuffer oldbuf = wxGTK_CONV( oldhotkey );
|
|
||||||
gtk_accelerator_parse( (const char*) oldbuf, &accel_key, &accel_mods);
|
gtk_accelerator_parse( (const char*) oldbuf, &accel_key, &accel_mods);
|
||||||
if (accel_key != 0)
|
if (accel_key != 0)
|
||||||
{
|
{
|
||||||
@@ -870,7 +869,6 @@ void wxMenuItem::SetText( const wxString& str )
|
|||||||
accel_mods,
|
accel_mods,
|
||||||
GTK_ACCEL_VISIBLE);
|
GTK_ACCEL_VISIBLE);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// it's valid for this function to be called even if m_menuItem == NULL
|
// it's valid for this function to be called even if m_menuItem == NULL
|
||||||
|
@@ -818,12 +818,13 @@ void wxMenuItem::SetText( const wxString& str )
|
|||||||
oldLabel = wxStripMenuCodes(oldLabel);
|
oldLabel = wxStripMenuCodes(oldLabel);
|
||||||
oldLabel.Replace(wxT("_"), wxT(""));
|
oldLabel.Replace(wxT("_"), wxT(""));
|
||||||
wxString label1 = wxStripMenuCodes(str);
|
wxString label1 = wxStripMenuCodes(str);
|
||||||
// Make sure we can change a hotkey even if the label is unaltered
|
wxString oldhotkey = GetHotKey(); // Store the old hotkey in Ctrl-foo format
|
||||||
wxString oldhotkey = GetHotKey();
|
wxCharBuffer oldbuf = wxGTK_CONV( GetGtkHotKey(*this) ); // and as <control>foo
|
||||||
|
|
||||||
DoSetText(str);
|
DoSetText(str);
|
||||||
|
|
||||||
if (oldLabel == label1 && oldhotkey == GetHotKey())
|
if (oldLabel == label1 &&
|
||||||
|
oldhotkey == GetHotKey()) // Make sure we can change a hotkey even if the label is unaltered
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (m_menuItem)
|
if (m_menuItem)
|
||||||
@@ -846,10 +847,8 @@ void wxMenuItem::SetText( const wxString& str )
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __WXGTK20__
|
|
||||||
guint accel_key;
|
guint accel_key;
|
||||||
GdkModifierType accel_mods;
|
GdkModifierType accel_mods;
|
||||||
wxCharBuffer oldbuf = wxGTK_CONV( oldhotkey );
|
|
||||||
gtk_accelerator_parse( (const char*) oldbuf, &accel_key, &accel_mods);
|
gtk_accelerator_parse( (const char*) oldbuf, &accel_key, &accel_mods);
|
||||||
if (accel_key != 0)
|
if (accel_key != 0)
|
||||||
{
|
{
|
||||||
@@ -870,7 +869,6 @@ void wxMenuItem::SetText( const wxString& str )
|
|||||||
accel_mods,
|
accel_mods,
|
||||||
GTK_ACCEL_VISIBLE);
|
GTK_ACCEL_VISIBLE);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// it's valid for this function to be called even if m_menuItem == NULL
|
// it's valid for this function to be called even if m_menuItem == NULL
|
||||||
|
Reference in New Issue
Block a user