mirror of https://github.com/OpenTTD/OpenTTD
Codechange: use StrEmpty instead of number of bytes in string to check for empty
parent
c5dac6e619
commit
f7aaf8ea24
|
@ -796,7 +796,7 @@ void QueryString::DrawEditBox(const Window *w, WidgetID wid) const
|
||||||
|
|
||||||
DrawFrameRect(cr, wi->colour, wi->IsLowered() ? FR_LOWERED : FR_NONE);
|
DrawFrameRect(cr, wi->colour, wi->IsLowered() ? FR_LOWERED : FR_NONE);
|
||||||
DrawSpriteIgnorePadding(rtl ? SPR_IMG_DELETE_RIGHT : SPR_IMG_DELETE_LEFT, PAL_NONE, cr, SA_CENTER);
|
DrawSpriteIgnorePadding(rtl ? SPR_IMG_DELETE_RIGHT : SPR_IMG_DELETE_LEFT, PAL_NONE, cr, SA_CENTER);
|
||||||
if (this->text.bytes == 1) GfxFillRect(cr.Shrink(WidgetDimensions::scaled.bevel), GetColourGradient(wi->colour, SHADE_DARKER), FILLRECT_CHECKER);
|
if (StrEmpty(this->text.GetText())) GfxFillRect(cr.Shrink(WidgetDimensions::scaled.bevel), GetColourGradient(wi->colour, SHADE_DARKER), FILLRECT_CHECKER);
|
||||||
|
|
||||||
DrawFrameRect(fr, wi->colour, FR_LOWERED | FR_DARKENED);
|
DrawFrameRect(fr, wi->colour, FR_LOWERED | FR_DARKENED);
|
||||||
GfxFillRect(fr.Shrink(WidgetDimensions::scaled.bevel), PC_BLACK);
|
GfxFillRect(fr.Shrink(WidgetDimensions::scaled.bevel), PC_BLACK);
|
||||||
|
@ -929,7 +929,7 @@ void QueryString::ClickEditBox(Window *w, Point pt, WidgetID wid, int click_coun
|
||||||
Rect cr = wi->GetCurrentRect().WithWidth(clearbtn_width, !rtl);
|
Rect cr = wi->GetCurrentRect().WithWidth(clearbtn_width, !rtl);
|
||||||
|
|
||||||
if (IsInsideMM(pt.x, cr.left, cr.right)) {
|
if (IsInsideMM(pt.x, cr.left, cr.right)) {
|
||||||
if (this->text.bytes > 1) {
|
if (!StrEmpty(this->text.GetText())) {
|
||||||
this->text.DeleteAll();
|
this->text.DeleteAll();
|
||||||
w->HandleButtonClick(wid);
|
w->HandleButtonClick(wid);
|
||||||
w->OnEditboxChanged(wid);
|
w->OnEditboxChanged(wid);
|
||||||
|
|
|
@ -2528,7 +2528,7 @@ EventState Window::HandleEditBoxKey(WidgetID wid, char32_t key, uint16_t keycode
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case QueryString::ACTION_CLEAR:
|
case QueryString::ACTION_CLEAR:
|
||||||
if (query->text.bytes <= 1) {
|
if (StrEmpty(query->text.GetText())) {
|
||||||
/* If already empty, unfocus instead */
|
/* If already empty, unfocus instead */
|
||||||
this->UnfocusFocusedWidget();
|
this->UnfocusFocusedWidget();
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue