Fix an off-by-1 bug in wxControl::FindAccelIndex() after "&&"
This resulted in wrong letter being underlined in wxGenericStaticText when the mnemonic occurred after "&&" (i.e. an actual ampersand) in the label. Add unit test which passes now, but would fail before on the last check.
This commit is contained in:
@@ -67,14 +67,23 @@ void DoTestLabel(wxControl* c)
|
||||
CHECK( l == wxControl::RemoveMnemonics(c->GetLabel()) );
|
||||
}
|
||||
|
||||
// Check that both "&" and "&" work in markup.
|
||||
#if wxUSE_MARKUP
|
||||
c->SetLabelMarkup("mnemonic in &markup");
|
||||
CHECK( c->GetLabel() == "mnemonic in &markup" );
|
||||
CHECK( c->GetLabelText() == "mnemonic in markup" );
|
||||
|
||||
c->SetLabelMarkup("mnemonic in &markup");
|
||||
CHECK( c->GetLabel() == "mnemonic in &markup" );
|
||||
CHECK( c->GetLabelText() == "mnemonic in markup" );
|
||||
|
||||
c->SetLabelMarkup("&& finally");
|
||||
CHECK( c->GetLabel() == "&& finally" );
|
||||
CHECK( c->GetLabelText() == "& finally" );
|
||||
|
||||
c->SetLabelMarkup("&& finally");
|
||||
CHECK( c->GetLabel() == "&& finally" );
|
||||
CHECK( c->GetLabelText() == "& finally" );
|
||||
#endif // wxUSE_MARKUP
|
||||
}
|
||||
|
||||
@@ -110,3 +119,12 @@ TEST_CASE("wxControl::RemoveMnemonics", "[wxControl][label][mnemonics]")
|
||||
CHECK( "&mnemonic" == wxControl::RemoveMnemonics("&&mnemonic") );
|
||||
CHECK( "&mnemonic" == wxControl::RemoveMnemonics("&&&mnemonic") );
|
||||
}
|
||||
|
||||
TEST_CASE("wxControl::FindAccelIndex", "[wxControl][label][mnemonics]")
|
||||
{
|
||||
CHECK( wxControl::FindAccelIndex("foo") == wxNOT_FOUND );
|
||||
CHECK( wxControl::FindAccelIndex("&foo") == 0 );
|
||||
CHECK( wxControl::FindAccelIndex("f&oo") == 1 );
|
||||
CHECK( wxControl::FindAccelIndex("foo && bar") == wxNOT_FOUND );
|
||||
CHECK( wxControl::FindAccelIndex("foo && &bar") == 6 );
|
||||
}
|
||||
|
Reference in New Issue
Block a user