@show6time wrote:
Good day.
I have a problem with EditBox.
When i entered text and hided ketboard, text is zooming out. I need have same size of text in entering mode and normal, so no zooming at all. Please, help me. I don't know what to do.Here code of EditBox creation.
EditBox* SearchBar::add_edit_box(string holder, Sprite* s_img, Node* node) { auto visibleSize = Director::getInstance()->getVisibleSize(); DeviceManager* device_manager = &DeviceManager::getInstance(); float height = node->getContentSize().height - SEARCH_IMG_OFF_T * visibleSize.height - SEARCH_IMG_OFF_B * visibleSize.height; float width = node->getContentSize().width - SEARCH_IMG_OFF_L * visibleSize.height - s_img->getContentSize().width; auto size = Size(width, height); auto b_sprite = Scale9Sprite::create(); auto edit_box = EditBox::create(size, b_sprite); edit_box->setFont("Default font", height/2); edit_box->setFontColor(Color3B::BLACK); h_str = holder; edit_box->setPlaceHolder(h_str.c_str()); edit_box->setPlaceholderFont("Default font", height/2); edit_box->setPlaceholderFontColor(Color3B::GRAY); edit_box->setMaxLength(99); edit_box->setInputMode(cocos2d::ui::EditBox::InputMode::SINGLE_LINE); edit_box->setInputFlag(cocos2d::ui::EditBox::InputFlag::INITIAL_CAPS_SENTENCE); edit_box->setReturnType(EditBox::KeyboardReturnType::SEARCH); edit_box->setDelegate(this); edit_box->setContentSize(size); edit_box->setAnchorPoint(Vec2(0.5f, 0.5f)); edit_box->ignoreAnchorPointForPosition(false); edit_box->setPosition(Vec2(s_img->getContentSize().width + size.width/2 + 2 * SEARCH_IMG_OFF_L * visibleSize.height, SEARCH_IMG_OFF_B * visibleSize.height + size.height/2)); node->addChild(edit_box); return edit_box; }
Posts: 1
Participants: 1