Merge pull request #54 from WenhaiLin/master

Fixed the initial placeholder of ui::TextField is incorrect.
This commit is contained in:
Wenhai Lin
2016-05-04 15:44:30 +08:00
3 changed files with 20 additions and 12 deletions
+1 -1
View File
@@ -120,7 +120,7 @@ bool TextFieldTTF::initWithPlaceHolder(const std::string& placeholder, const Siz
}
bool TextFieldTTF::initWithPlaceHolder(const std::string& placeholder, const std::string& fontName, float fontSize)
{
_placeHolder = std::string(placeholder);
_placeHolder = placeholder;
setSystemFontName(fontName);
setSystemFontSize(fontSize);
Label::setTextColor(_colorSpaceHolder);
+17 -9
View File
@@ -194,17 +194,25 @@ double atof(const char* str)
return 0.0;
}
char buf[MAX_ITOA_BUFFER_SIZE];
strncpy(buf, str, MAX_ITOA_BUFFER_SIZE);
// strip string, only remain 7 numbers after '.'
char* dot = strchr(buf, '.');
if (dot != nullptr && dot - buf + 8 < MAX_ITOA_BUFFER_SIZE)
auto dot = strchr(str, '.');
if (dot == nullptr)
{
dot[8] = '\0';
return std::atof(str);
}
else
{
char buf[MAX_ITOA_BUFFER_SIZE];
strncpy(buf, str, MAX_ITOA_BUFFER_SIZE);
// strip string, only remain 7 numbers after '.'
auto index = dot - str + 8;
if (index < MAX_ITOA_BUFFER_SIZE)
{
buf[index] = '\0';
}
return std::atof(buf);
}
return ::atof(buf);
}
double gettime()
+2 -2
View File
@@ -67,10 +67,10 @@ UICCTextField * UICCTextField::create(const std::string& placeholder, const std:
void UICCTextField::onEnter()
{
TextFieldTTF::onEnter();
TextFieldTTF::setDelegate(this);
}
bool UICCTextField::onTextFieldAttachWithIME(TextFieldTTF *pSender)
{
setAttachWithIME(true);
@@ -368,7 +368,7 @@ void TextField::onEnter()
void TextField::initRenderer()
{
_textFieldRenderer = UICCTextField::create("input words here", "Thonburi", 20);
_textFieldRenderer = UICCTextField::create("", "Thonburi", 20);
addProtectedChild(_textFieldRenderer, TEXTFIELD_RENDERER_Z, -1);
}