rewrote LineEdit window repositioning code so it does not eat the last character, closes #4992
This commit is contained in:
parent
1785f6939f
commit
83bf8036de
|
@ -731,14 +731,21 @@ void LineEdit::set_cursor_pos(int p_pos) {
|
||||||
int width_to_cursor=0;
|
int width_to_cursor=0;
|
||||||
int wp=window_pos;
|
int wp=window_pos;
|
||||||
|
|
||||||
if (font != NULL) {
|
if (font.is_valid()) {
|
||||||
for (int i=window_pos;i<cursor_pos;i++)
|
|
||||||
width_to_cursor+=font->get_char_size( text[i] ).width;
|
|
||||||
|
|
||||||
while (width_to_cursor >= window_width && wp < text.length()) {
|
int accum_width=0;
|
||||||
|
|
||||||
width_to_cursor -= font->get_char_size(text[wp]).width;
|
for(int i=cursor_pos;i>=window_pos;i--) {
|
||||||
wp++;
|
|
||||||
|
if (i>=text.length()) {
|
||||||
|
accum_width=font->get_char_size(' ').width; //anything should do
|
||||||
|
} else {
|
||||||
|
accum_width+=font->get_char_size(text[i],i+1<text.length()?text[i+1]:0).width; //anything should do
|
||||||
|
}
|
||||||
|
if (accum_width>=window_width)
|
||||||
|
break;
|
||||||
|
|
||||||
|
wp=i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -583,6 +583,7 @@ ThemeEditor::ThemeEditor() {
|
||||||
add_child(panel);
|
add_child(panel);
|
||||||
panel->set_area_as_parent_rect(0);
|
panel->set_area_as_parent_rect(0);
|
||||||
panel->set_margin(MARGIN_TOP,25);
|
panel->set_margin(MARGIN_TOP,25);
|
||||||
|
panel->set_theme(Theme::get_default());
|
||||||
|
|
||||||
main_vb= memnew( VBoxContainer );
|
main_vb= memnew( VBoxContainer );
|
||||||
panel->add_child(main_vb);
|
panel->add_child(main_vb);
|
||||||
|
|
Loading…
Reference in New Issue