I’m using TextEditor::getTextIndexAt(x, y) in order to find which word the cursor is currently over.
I am subtracting the border left from the x and border top from the y coordinates of the mouse event (missing from getTextIndexAt(x, y) I guess, as the indent is being subtracted).
The TextEditor is set to automatically show the vertical and horizontal scroll bars if needed, but does not show them because the text can easily fit into the TextEditor
int TextEditor::getTextIndexAt (const int x,
const int y)
return indexAtPosition ((float) (x + viewport->getViewPositionX() - leftIndent),
(float) (y + viewport->getViewPositionY() - topIndent));
For some reason, viewport->getViewPositionY() is not 0, resulting in an incorrect index returned; its like the TextEditor thinks it has scroll bars (shows a partial viewed component), only it doesn’t - it shows it completely.
When I shrink it enough for the scrolls bars to actually appear, it works.
I know I don’t supply a lot of details, but that’s all I’ve got.
Any help will be appreciated.