Skip to content

Commit c2120b3

Browse files
committed
UI: minor form fix
1 parent 8aee2cb commit c2120b3

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

src/ui/inputs.cpp

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -138,14 +138,9 @@ void FormInput::construct(var_p_t form, var_p_t field, int id) {
138138
}
139139

140140
const char *caption = getText();
141-
int textW = 0;
142-
int textH = 0;
143-
144-
if (caption) {
145-
MAExtent extent = maGetTextSize(caption);
146-
textW = EXTENT_X(extent);
147-
textH = EXTENT_Y(extent);
148-
}
141+
MAExtent extent = maGetTextSize(caption != NULL && caption[0] ? caption : "Z");
142+
int textW = EXTENT_X(extent);
143+
int textH = EXTENT_Y(extent);
149144

150145
if (_width <= 0 && caption != NULL) {
151146
_width = textW + padding(false);
@@ -572,7 +567,7 @@ void FormLineInput::draw(int x, int y, int w, int h, int chw) {
572567
maFillRect(px, y, width, _height);
573568
maSetColor(_bg);
574569
maDrawText(px, y, _buffer + _scroll + start, chars);
575-
} else {
570+
} else if (hasFocus()) {
576571
int px = x + (_point * chw);
577572
maFillRect(px, y, chw, _height);
578573
if (_point < len) {

0 commit comments

Comments
 (0)