Fix #113735: Space Characters in UI Text Entry
With #113707 text cursor position is set using the character's visible bounds, so special care is needed for those without bounds like space. Pull Request: https://projects.blender.org/blender/blender/pulls/113749
This commit is contained in:
committed by
Harley Acheson
parent
1423ece1eb
commit
c6c86b555d
@@ -2054,10 +2054,15 @@ static void widget_draw_text(const uiFontStyle *fstyle,
|
||||
bool has_prev = false;
|
||||
if (pos > 0) {
|
||||
if (BLF_str_offset_to_glyph_bounds(
|
||||
fstyle->uifont_id, drawstr + but->ofs, pos - 1, &bounds) &&
|
||||
!BLI_rcti_is_empty(&bounds))
|
||||
fstyle->uifont_id, drawstr + but->ofs, pos - 1, &bounds))
|
||||
{
|
||||
prev_right_edge = bounds.xmax;
|
||||
if (bounds.xmax > bounds.xmin) {
|
||||
prev_right_edge = bounds.xmax;
|
||||
}
|
||||
else {
|
||||
/* Some characters, like space, have empty bounds. */
|
||||
prev_right_edge = BLF_width(fstyle->uifont_id, drawstr + but->ofs, pos);
|
||||
}
|
||||
has_prev = true;
|
||||
}
|
||||
}
|
||||
@@ -2066,9 +2071,7 @@ static void widget_draw_text(const uiFontStyle *fstyle,
|
||||
int next_left_edge = 0;
|
||||
bool has_next = false;
|
||||
if (pos < strlen(drawstr)) {
|
||||
if (BLF_str_offset_to_glyph_bounds(
|
||||
fstyle->uifont_id, drawstr + but->ofs, pos, &bounds) &&
|
||||
!BLI_rcti_is_empty(&bounds))
|
||||
if (BLF_str_offset_to_glyph_bounds(fstyle->uifont_id, drawstr + but->ofs, pos, &bounds))
|
||||
{
|
||||
next_left_edge = bounds.xmin;
|
||||
has_next = true;
|
||||
|
||||
Reference in New Issue
Block a user