1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-07-03 00:46:55 +02:00

- fixes #1424 - added missing override and CLabel::visibleText()

This commit is contained in:
Ivan Savenko
2013-09-01 17:34:46 +00:00
parent 7f43150bb9
commit 708b0c6f47
2 changed files with 12 additions and 4 deletions

View File

@ -1156,12 +1156,17 @@ void LRClickableAreaWText::init()
addUsedEvents(LCLICK | RCLICK | HOVER); addUsedEvents(LCLICK | RCLICK | HOVER);
} }
std::string CLabel::visibleText()
{
return text;
}
void CLabel::showAll(SDL_Surface * to) void CLabel::showAll(SDL_Surface * to)
{ {
CIntObject::showAll(to); CIntObject::showAll(to);
if(!text.empty()) if(!visibleText().empty())
blitLine(to, pos, text); blitLine(to, pos, visibleText());
} }
@ -1177,7 +1182,7 @@ CLabel::CLabel(int x, int y, EFonts Font /*= FONT_SMALL*/, EAlignment Align, con
if (alignment == TOPLEFT) // causes issues for MIDDLE if (alignment == TOPLEFT) // causes issues for MIDDLE
{ {
pos.w = graphics->fonts[font]->getStringWidth(text.c_str()); pos.w = graphics->fonts[font]->getStringWidth(visibleText().c_str());
pos.h = graphics->fonts[font]->getLineHeight(); pos.h = graphics->fonts[font]->getLineHeight();
} }
} }
@ -1576,6 +1581,8 @@ void CTextInput::keyPressed( const SDL_KeyboardEvent & key )
std::string oldText = text; std::string oldText = text;
switch(key.keysym.sym) switch(key.keysym.sym)
{ {
case SDLK_DELETE: // have index > ' ' so it won't be filtered out by default section
return;
case SDLK_BACKSPACE: case SDLK_BACKSPACE:
if(!text.empty()) if(!text.empty())
text.resize(text.size()-1); text.resize(text.size()-1);

View File

@ -348,6 +348,7 @@ class CLabel : public CTextContainer
{ {
protected: protected:
Point getBorderSize() override; Point getBorderSize() override;
virtual std::string visibleText();
CPicture *bg; CPicture *bg;
public: public:
@ -449,7 +450,7 @@ public:
class CTextInput : public CLabel, public CFocusable class CTextInput : public CLabel, public CFocusable
{ {
protected: protected:
std::string visibleText(); std::string visibleText() override;
public: public:
CFunctionList<void(const std::string &)> cb; CFunctionList<void(const std::string &)> cb;