Merge pull request #58699 from Calinou/lineedit-textedit-fix-caret-disappearing

Fix LineEdit and TextEdit carets disappearing at theme scales below 1.0
This commit is contained in:
Rémi Verschelde 2022-03-03 08:08:37 +01:00 committed by GitHub
commit 33fc69dfb0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View file

@ -847,7 +847,8 @@ void LineEdit::_notification(int p_what) {
// Draw carets.
ofs.x = x_ofs + scroll_offset;
if (draw_caret || drag_caret_force_displayed) {
const int caret_width = get_theme_constant(SNAME("caret_width")) * get_theme_default_base_scale();
// Prevent carets from disappearing at theme scales below 1.0 (if the caret width is 1).
const int caret_width = get_theme_constant(SNAME("caret_width")) * MAX(1, get_theme_default_base_scale());
if (ime_text.length() == 0) {
// Normal caret.

View file

@ -1283,7 +1283,8 @@ void TextEdit::_notification(int p_what) {
}
// Carets.
const int caret_width = get_theme_constant(SNAME("caret_width")) * get_theme_default_base_scale();
// Prevent carets from disappearing at theme scales below 1.0 (if the caret width is 1).
const int caret_width = get_theme_constant(SNAME("caret_width")) * MAX(1, get_theme_default_base_scale());
if (!clipped && caret.line == line && line_wrap_index == caret_wrap_index) {
caret.draw_pos.y = ofs_y + ldata->get_line_descent(line_wrap_index);