improve editbox test and font creation

This commit is contained in:
zilongshanren 2016-06-23 15:57:41 +08:00
parent bac1870d16
commit a6b0ea76de
3 changed files with 9 additions and 3 deletions

View File

@ -227,6 +227,9 @@ UIFont* EditBoxImplIOS::constructFont(const char *fontName, int fontSize)
if (strlen(fontName) > 0)
{
textFont = [UIFont fontWithName:fntName size:fontSize];
if (textFont == nil) {
textFont = [UIFont systemFontOfSize:fontSize];
}
}
else
{

View File

@ -98,6 +98,9 @@ NSFont* EditBoxImplMac::constructFont(const char *fontName, int fontSize)
else
{
textFont = [NSFont fontWithName:fntName size:fontSize];
if (textFont == nil) {
textFont = [NSFont systemFontOfSize:fontSize];
}
}
return textFont;

View File

@ -57,13 +57,13 @@ bool UIEditBoxTest::init()
// top
std::string pNormalSprite = "extensions/green_edit.png";
_editName = ui::EditBox::create(editBoxSize + Size(0,40), ui::Scale9Sprite::create(pNormalSprite));
_editName->setPosition(Vec2(visibleOrigin.x+visibleSize.width/2-50, visibleOrigin.y+visibleSize.height*3/4));
_editName = ui::EditBox::create(editBoxSize + Size(0,20), ui::Scale9Sprite::create(pNormalSprite));
_editName->setPosition(Vec2(visibleOrigin.x+visibleSize.width/2-60, visibleOrigin.y+visibleSize.height*3/4 - 20));
_editName->setFontColor(Color3B::RED);
_editName->setPlaceHolder("Name:");
_editName->setPlaceholderFontColor(Color3B::WHITE);
_editName->setMaxLength(8);
_editName->setFontSize(editBoxSize.height/2);
_editName->setFontSize(editBoxSize.height/3);
_editName->setText("v👐👊💝");
_editName->setReturnType(ui::EditBox::KeyboardReturnType::DONE);
_editName->setDelegate(this);