Apply a better fix for HitTest failures in the tests with GTK3

The actual cause of the problem was the tests making the single-line
text control height far too large. So just use the default height for
single-line controls.
This commit is contained in:
Paul Cornett 2021-01-19 22:50:41 -08:00
parent c530b89ffa
commit 892795ac9c
2 changed files with 5 additions and 13 deletions

View File

@ -1582,17 +1582,7 @@ wxTextCtrl::HitTest(const wxPoint& pt, long *pos) const
gtk_entry_get_layout_offsets(GTK_ENTRY(m_text), &ofsX, &ofsY);
x -= ofsX;
// There is something really weird going on with vertical offset under
// GTK 3: normally it is just 0, because a single line control doesn't
// scroll vertically anyhow, but sometimes it can have big positive or
// negative values after scrolling horizontally, resulting in test
// failures in TextCtrlTestCase::HitTestSingleLine::Scrolled. So just
// ignore it completely, as, again, it shouldn't matter for single line
// text controls in any case, and so do not do this:
#ifndef __WXGTK3__
y -= ofsY;
#endif // !__WXGTK3__
// And scale the coordinates for Pango.
x *= PANGO_SCALE;

View File

@ -166,14 +166,16 @@ long TextCtrlTestCase::ms_style = 0;
void TextCtrlTestCase::CreateText(long extraStyles)
{
const long style = ms_style | extraStyles;
const int h = (style & wxTE_MULTILINE) ? TEXT_HEIGHT : -1;
m_text = new wxTextCtrl(wxTheApp->GetTopWindow(), wxID_ANY, "",
wxDefaultPosition, wxSize(400, TEXT_HEIGHT),
ms_style | extraStyles);
wxDefaultPosition, wxSize(400, h),
style);
}
void TextCtrlTestCase::setUp()
{
CreateText(ms_style);
CreateText(0);
}
void TextCtrlTestCase::tearDown()