EditBox 메서드
h++)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | #ifndef test388_hpp #define test388_hpp #include "cocos2d.h" #include "cocos-ext.h" USING_NS_CC; USING_NS_CC_EXT; class Test388 : public Layer { public: virtual bool init(); static Scene* createScene(); CREATE_FUNC(Test388); }; #endif | cs |
c++)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | #include "test388.hpp" USING_NS_CC; Scene* Test388::createScene() { auto scene = Scene::create(); auto layer = Test388::create(); scene->addChild(layer); return scene; } bool Test388::init() { if ( !Layer::init()) { return false; } auto editBox = EditBox::create(Size(400, 50), Scale9Sprite::create("green_edit.png")); editBox->setPosition(Point(240, 160)); editBox->setPlaceHolder("NAME : "); editBox->setMaxLength(8); this->addChild(editBox); //Placeholder의 폰트 종류와 크기 editBox->setPlaceholderFont("", 30); //Placeholder의 폰트색 editBox->setPlaceholderFontColor(Color3B::BLUE); //폰트 종류와 크기 editBox->setFont("", 20); //폰트색 editBox->setFontColor(Color3B::RED); //setReturnType : 키보드의 리턴키 종류 /** EditBox::KeyboardReturnType::DEFAULT EditBox::KeyboardReturnType::DONE EditBox::KeyboardReturnType::SEND EditBox::KeyboardReturnType::SEARCH EditBox::KeyboardReturnType::GO */ editBox->setReturnType(EditBox::KeyboardReturnType::SEARCH); //setInputMode : 키보드 입력모드 /** EditBox::InputMode::ANY 기본 EditBox::InputMode::EMAIL_ADDRESS 이메일주소 EditBox::InputMode::NUMERIC 숫자, 특수문자 EditBox::InputMode::PHONE_NUMBER 전화번호 EditBox::InputMode::URL URL EditBox::InputMode::DECIMAL 숫자 실수점 */ editBox->setInputMode(EditBox::InputMode::NUMERIC); //setInputFlag : 키보드 입력 플래그 /** EditBox::InputFlag::PASSWORD 비밀번호 입력플래그 EditBox::InputFlag::SENSITIVE 추천기능 없음 EditBox::InputFlag::INITIAL_CAPS_WORD 단어마다 추천기능 EditBox::InputFlag::INITIAL_CAPS_SENTENCE 문장마다 추천기능 EditBox::InputFlag::INITIAL_CAPS_ALL_CHARACTERS 글자마다 추천기능 */ editBox->setInputFlag(EditBox::InputFlag::PASSWORD); return true; } | cs |
결과
숫자만 입력가능하며 문자대신 *로 표시
'IT > - 프로그래밍' 카테고리의 다른 글
IOS Hello World! 출력 (0) | 2017.03.30 |
---|---|
Cocos 에디트박스 Delegate (0) | 2017.03.29 |
Cocos 에디트박스 생성하기 (0) | 2017.03.27 |
안드로이드 ANT 설치 (0) | 2017.03.26 |
Cocos Scale9Sprite 사용하기 (0) | 2017.03.26 |