mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-06 14:27:16 +00:00
Codechange: use StrEmpty instead of number of bytes in string to check for empty
This commit is contained in:
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);
|
||||
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);
|
||||
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);
|
||||
|
||||
if (IsInsideMM(pt.x, cr.left, cr.right)) {
|
||||
if (this->text.bytes > 1) {
|
||||
if (!StrEmpty(this->text.GetText())) {
|
||||
this->text.DeleteAll();
|
||||
w->HandleButtonClick(wid);
|
||||
w->OnEditboxChanged(wid);
|
||||
|
@ -2528,7 +2528,7 @@ EventState Window::HandleEditBoxKey(WidgetID wid, char32_t key, uint16_t keycode
|
||||
break;
|
||||
|
||||
case QueryString::ACTION_CLEAR:
|
||||
if (query->text.bytes <= 1) {
|
||||
if (StrEmpty(query->text.GetText())) {
|
||||
/* If already empty, unfocus instead */
|
||||
this->UnfocusFocusedWidget();
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user