Make it simpler to use mnemonics for wxRadioBox items in XRC
Allow specifying label="1" attribute in wxRadioBox <item> tags to indicate that the usual translation of "_" to "&" should be done, as for all the other labels. This is still not the default behaviour to avoid breaking any existing XRC files using "_", even though using labels="1" by default would make more sense.
This commit is contained in:
parent
bc2c9ce2a3
commit
3357d46ccc
@ -1595,6 +1595,11 @@ can also have some optional XML @em attributes (not properties!):
|
||||
Is the button enabled (default: 1)?}
|
||||
@row3col{hidden, @ref overview_xrcformat_type_bool,
|
||||
Is the button hidden initially (default: 0)?}
|
||||
@row3col{label, @ref overview_xrcformat_type_bool,
|
||||
Should this item text be interpreted as a label, i.e. escaping underscores
|
||||
in it as done for the label properties of other controls? This attribute
|
||||
exists since wxWidgets 3.1.1 and was always treated as having the value of
|
||||
0, which still remains its default, until then.}
|
||||
@endTable
|
||||
|
||||
Example:
|
||||
|
@ -1225,6 +1225,7 @@ wxRadioBox =
|
||||
attribute helptext { t_string }?,
|
||||
attribute enabled { t_bool }?,
|
||||
attribute hidden { t_bool }?,
|
||||
attribute label { t_bool }?,
|
||||
t_text
|
||||
}*
|
||||
}?
|
||||
|
@ -107,7 +107,13 @@ wxObject *wxRadioBoxXmlHandler::DoCreateResource()
|
||||
// we handle handle <item>Label</item> constructs here, and the item
|
||||
// tag can have tooltip, helptext, enabled and hidden attributes
|
||||
|
||||
m_labels.push_back(GetNodeText(m_node, wxXRC_TEXT_NO_ESCAPE));
|
||||
// For compatibility, labels are not escaped in XRC by default and
|
||||
// label="1" attribute needs to be explicitly specified to handle them
|
||||
// consistently with the other labels.
|
||||
m_labels.push_back(GetNodeText(m_node,
|
||||
GetBoolAttr("label", 0)
|
||||
? 0
|
||||
: wxXRC_TEXT_NO_ESCAPE));
|
||||
#if wxUSE_TOOLTIPS
|
||||
m_tooltips.push_back(GetNodeText(GetParamNode(wxT("tooltip")),
|
||||
wxXRC_TEXT_NO_ESCAPE));
|
||||
|
@ -981,9 +981,14 @@ GetNodeContentsKind(wxXmlNode& node, const wxString& contents)
|
||||
}
|
||||
|
||||
// This one is special: it is translated in XRC, but its contents is not
|
||||
// escaped.
|
||||
// escaped, except for the special case of wxRadioBox when it can be, if
|
||||
// "label" attribute is supplied.
|
||||
if ( node.GetName() == wxT("item") )
|
||||
return Contents_TransOnly;
|
||||
{
|
||||
return node.GetAttribute(wxT("label"), wxT("0")) == wxT("1")
|
||||
? Contents_Text
|
||||
: Contents_TransOnly;
|
||||
}
|
||||
|
||||
return Contents_NotTrans;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user