From 9e81f4de89d8625757578f152833a6e1f71c997a Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Fri, 4 Aug 2017 07:46:57 +0200 Subject: GRAPHICS: MACGUI: Better selection row detection --- graphics/macgui/mactext.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'graphics') diff --git a/graphics/macgui/mactext.cpp b/graphics/macgui/mactext.cpp index ade339f2e5..4647f9c300 100644 --- a/graphics/macgui/mactext.cpp +++ b/graphics/macgui/mactext.cpp @@ -449,15 +449,13 @@ void MacText::getRowCol(int x, int y, int *sx, int *sy, int *row, int *col) { CLIP(y, 0, _textMaxHeight); // FIXME: We should use bsearch() here - *row = 0; + *row = _textLines.size() - 1; - while (*row < _textLines.size() && _textLines[*row].y < y) - (*row)++; - - if (*row == _textLines.size()) { + while (*row && _textLines[*row].y > y) (*row)--; + + if (y > _textMaxHeight) x = getLineWidth(*row); - } *sy = _textLines[*row].y; -- cgit v1.2.3