Ignore initially specified labels for buttons with wxBU_NOTEXT

It doesn't make much sense to specify a non-empty label and wxBU_NOTEXT style
together, but if this happens, the label should be ignored, as it was already
done by wxGTK, but not wxMSW and wxOSX -- so add the missing checks for
wxBU_NOTEXT to these ports too.

Closes #17152.
This commit is contained in:
Vadim Zeitlin
2016-02-01 01:29:03 +01:00
parent a0548db9f5
commit 9b39ffc0cb
2 changed files with 22 additions and 15 deletions

View File

@@ -82,17 +82,21 @@ bool wxButton::Create(wxWindow *parent,
const wxValidator& validator, const wxValidator& validator,
const wxString& name) const wxString& name)
{ {
wxString label(lbl); wxString label;
if (label.empty() && wxIsStockID(id)) if ( !(style & wxBU_NOTEXT) )
{ {
// On Windows, some buttons aren't supposed to have mnemonics label = lbl;
label = wxGetStockLabel if (label.empty() && wxIsStockID(id))
( {
id, // On Windows, some buttons aren't supposed to have mnemonics
id == wxID_OK || id == wxID_CANCEL || id == wxID_CLOSE label = wxGetStockLabel
? wxSTOCK_NOFLAGS (
: wxSTOCK_WITH_MNEMONIC id,
); id == wxID_OK || id == wxID_CANCEL || id == wxID_CLOSE
? wxSTOCK_NOFLAGS
: wxSTOCK_WITH_MNEMONIC
);
}
} }
if ( !CreateControl(parent, id, pos, size, style, validator, name) ) if ( !CreateControl(parent, id, pos, size, style, validator, name) )

View File

@@ -69,12 +69,15 @@ bool wxButton::Create(wxWindow *parent,
wxString label; wxString label;
// Ignore the standard label for help buttons if possible, they use "?" if ( !(style & wxBU_NOTEXT) )
// label under Mac which looks better.
if ( !IsHelpButtonWithStandardLabel(id, labelOrig) )
{ {
label = labelOrig.empty() && wxIsStockID(id) ? wxGetStockLabel(id) // Ignore the standard label for help buttons if possible, they use "?"
: labelOrig; // label under Mac which looks better.
if ( !IsHelpButtonWithStandardLabel(id, labelOrig) )
{
label = labelOrig.empty() && wxIsStockID(id) ? wxGetStockLabel(id)
: labelOrig;
}
} }