From 55a241494e0045d6e9a6b573e4d2cae3f390244f Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Fri, 4 Aug 2017 07:34:13 +0200 Subject: GRAPHICS: MACGUI: Improved text selection edge case behaviour --- graphics/macgui/mactext.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'graphics/macgui/mactext.cpp') diff --git a/graphics/macgui/mactext.cpp b/graphics/macgui/mactext.cpp index 64a8ebfd17..ade339f2e5 100644 --- a/graphics/macgui/mactext.cpp +++ b/graphics/macgui/mactext.cpp @@ -451,11 +451,13 @@ void MacText::getRowCol(int x, int y, int *sx, int *sy, int *row, int *col) { // FIXME: We should use bsearch() here *row = 0; - while (*row < _textLines.size() - 1 && _textLines[*row].y < y) + while (*row < _textLines.size() && _textLines[*row].y < y) (*row)++; - if (*row) + if (*row == _textLines.size()) { (*row)--; + x = getLineWidth(*row); + } *sy = _textLines[*row].y; @@ -464,7 +466,7 @@ void MacText::getRowCol(int x, int y, int *sx, int *sy, int *row, int *col) { int width = 0, pwidth = 0; int mcol = 0, pmcol = 0; uint chunk; - for (chunk = 0; chunk < _textLines[*row].chunks.size() - 1; chunk++) { + for (chunk = 0; chunk < _textLines[*row].chunks.size(); chunk++) { pwidth = width; pmcol = mcol; if (!_textLines[*row].chunks[chunk].text.empty()) { @@ -476,6 +478,9 @@ void MacText::getRowCol(int x, int y, int *sx, int *sy, int *row, int *col) { break; } + if (chunk == _textLines[*row].chunks.size()) + chunk--; + Common::String str = _textLines[*row].chunks[chunk].text; *col = mcol; -- cgit v1.2.3