浏览代码

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

Ivan Savenko 12 年之前
父节点
当前提交
708b0c6f47
共有 2 个文件被更改,包括 12 次插入4 次删除
  1. 10 3
      client/gui/CIntObjectClasses.cpp
  2. 2 1
      client/gui/CIntObjectClasses.h

+ 10 - 3
client/gui/CIntObjectClasses.cpp

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

+ 2 - 1
client/gui/CIntObjectClasses.h

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