fix: TextBox.setCaret fails when font is not ready
This commit is contained in:
@@ -640,8 +640,10 @@ size_t TextBox::getCaret() const {
|
|||||||
|
|
||||||
void TextBox::setCaret(size_t position) {
|
void TextBox::setCaret(size_t position) {
|
||||||
this->caret = std::min(static_cast<size_t>(position), input.length());
|
this->caret = std::min(static_cast<size_t>(position), input.length());
|
||||||
|
if (font == nullptr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
caretLastMove = Window::time();
|
caretLastMove = Window::time();
|
||||||
|
|
||||||
int width = label->getSize().x;
|
int width = label->getSize().x;
|
||||||
uint line = label->getLineByTextIndex(caret);
|
uint line = label->getLineByTextIndex(caret);
|
||||||
int offset = label->getLineYOffset(line) + contentOffset().y;
|
int offset = label->getLineYOffset(line) + contentOffset().y;
|
||||||
|
|||||||
Reference in New Issue
Block a user