Text box shows text near the cursor when being edited

This commit is contained in:
Yousef Khadadeh 2025-10-01 10:50:42 +03:00
parent 278792a0ff
commit 220eb34ab9

View file

@ -150,7 +150,12 @@ template <typename T> class TextBox : public Element {
canvas->clipRect(SkRect::MakeXYWH(bb.min.x(), bb.min.y(), bb.width(), bb.height()));
canvas->translate(bb.min.x(), bb.min.y());
if(singleLine && selection.selected) {
SkRect cursorRect = textbox.getLocation(cur.pos);
canvas->translate(bb.min.x() - std::max(cursorRect.fRight - bb.width(), 0.0f), bb.min.y());
}
else
canvas->translate(bb.min.x(), bb.min.y());
textbox.setFont(SkFont(io.textTypeface, io.fontSize));
textbox.setFontMgr(io.textFontMgr);