Skip to content

Commit 66dd289

Browse files
committed
Merge pull request #100208 from eviltrout/highlight-bg-fix
Fix user selection on top of `bgcolor` areas in a `RichTextLabel`
2 parents e188cf6 + 1e749f6 commit 66dd289

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

scene/gui/rich_text_label.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1370,6 +1370,13 @@ int RichTextLabel::_draw_line(ItemFrame *p_frame, int p_line, const Vector2 &p_o
13701370
}
13711371
}
13721372
// Finish lines and boxes.
1373+
if (step == DRAW_STEP_BACKGROUND || step == DRAW_STEP_FOREGROUND) {
1374+
if (last_color.a > 0.0) {
1375+
Vector2 rect_off = p_ofs + Vector2(box_start - theme_cache.text_highlight_h_padding, off_step.y - l_ascent - theme_cache.text_highlight_v_padding);
1376+
Vector2 rect_size = Vector2(off_step.x - box_start + 2 * theme_cache.text_highlight_h_padding, l_size.y + 2 * theme_cache.text_highlight_v_padding);
1377+
RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(rect_off, rect_size), last_color);
1378+
}
1379+
}
13731380
if (step == DRAW_STEP_BACKGROUND) {
13741381
if (sel_start != -1) {
13751382
Color selection_bg = theme_cache.selection_color;
@@ -1380,13 +1387,6 @@ int RichTextLabel::_draw_line(ItemFrame *p_frame, int p_line, const Vector2 &p_o
13801387
}
13811388
}
13821389
}
1383-
if (step == DRAW_STEP_BACKGROUND || step == DRAW_STEP_FOREGROUND) {
1384-
if (last_color.a > 0.0) {
1385-
Vector2 rect_off = p_ofs + Vector2(box_start - theme_cache.text_highlight_h_padding, off_step.y - l_ascent - theme_cache.text_highlight_v_padding);
1386-
Vector2 rect_size = Vector2(off_step.x - box_start + 2 * theme_cache.text_highlight_h_padding, l_size.y + 2 * theme_cache.text_highlight_v_padding);
1387-
RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(rect_off, rect_size), last_color);
1388-
}
1389-
}
13901390
if (step == DRAW_STEP_TEXT) {
13911391
if (ul_started) {
13921392
ul_started = false;

0 commit comments

Comments
 (0)