mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-04 10:32:39 +08:00
Merge pull request #54 from WenhaiLin/master
Fixed the initial placeholder of ui::TextField is incorrect.
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user