mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-04 10:32:39 +08:00
Merge pull request #307 from zilongshanren/fix-merge-issues-1.3
Fix merge issues 1.3
This commit is contained in:
@@ -132,6 +132,42 @@ public class Cocos2dxEditBox extends EditText {
|
||||
this.setLayoutParams(layoutParams);
|
||||
}
|
||||
|
||||
public void setInputTextAlignment(int hAlign, int vAlign) {
|
||||
int gravity;
|
||||
|
||||
switch (hAlign) {
|
||||
case 0:
|
||||
gravity = Gravity.LEFT;
|
||||
break;
|
||||
case 1:
|
||||
gravity = Gravity.CENTER_HORIZONTAL;
|
||||
break;
|
||||
case 2:
|
||||
gravity = Gravity.RIGHT;
|
||||
break;
|
||||
default:
|
||||
gravity = Gravity.LEFT;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (vAlign) {
|
||||
case 0:
|
||||
gravity = gravity | Gravity.TOP;
|
||||
break;
|
||||
case 1:
|
||||
gravity = gravity | Gravity.CENTER_VERTICAL;
|
||||
break;
|
||||
case 2:
|
||||
gravity = gravity | Gravity.BOTTOM;
|
||||
break;
|
||||
default:
|
||||
gravity = gravity | Gravity.CENTER_VERTICAL;
|
||||
break;
|
||||
}
|
||||
|
||||
this.setGravity(gravity);
|
||||
}
|
||||
|
||||
public float getOpenGLViewScaleX() {
|
||||
return mScaleX;
|
||||
}
|
||||
@@ -175,10 +211,11 @@ public class Cocos2dxEditBox extends EditText {
|
||||
}
|
||||
|
||||
public void setInputMode(int inputMode){
|
||||
|
||||
this.setInputTextAlignment(0, 1);
|
||||
switch (inputMode) {
|
||||
case kEditBoxInputModeAny:
|
||||
this.mInputModeConstraints = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE;
|
||||
this.setInputTextAlignment(0, 0);
|
||||
break;
|
||||
case kEditBoxInputModeEmailAddr:
|
||||
this.mInputModeConstraints = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS;
|
||||
|
||||
+28
-14
@@ -67,6 +67,10 @@ public class Cocos2dxEditBoxHelper {
|
||||
editBoxEditingDidEnd(index, text);
|
||||
}
|
||||
|
||||
private static native void editBoxEditingReturn(int index);
|
||||
public static void __editBoxEditingReturn(int index) {
|
||||
editBoxEditingReturn(index);
|
||||
}
|
||||
|
||||
public Cocos2dxEditBoxHelper(ResizeLayout layout) {
|
||||
Cocos2dxEditBoxHelper.mFrameLayout = layout;
|
||||
@@ -124,7 +128,7 @@ public class Cocos2dxEditBoxHelper {
|
||||
lParams.gravity = Gravity.TOP | Gravity.LEFT;
|
||||
|
||||
mFrameLayout.addView(editBox, lParams);
|
||||
|
||||
editBox.setTag(false);
|
||||
editBox.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
@@ -132,23 +136,20 @@ public class Cocos2dxEditBoxHelper {
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
//The optimization can't be turn on due to unknown keyboard hide in some custom keyboard
|
||||
// mFrameLayout.setEnableForceDoLayout(false);
|
||||
|
||||
// Note that we must to copy a string to prevent string content is modified
|
||||
// on UI thread while 's.toString' is invoked at the same time.
|
||||
final String text = new String(s.toString());
|
||||
mCocos2dxActivity.runOnGLThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Cocos2dxEditBoxHelper.__editBoxEditingChanged(index, text);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//http://stackoverflow.com/questions/21713246/addtextchangedlistener-and-ontextchanged-are-always-called-when-android-fragment
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
|
||||
public void afterTextChanged(final Editable s) {
|
||||
if(!s.toString().equals("") && (Boolean)editBox.getTag()) {
|
||||
mCocos2dxActivity.runOnGLThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Cocos2dxEditBoxHelper.__editBoxEditingChanged(index, s.toString());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -157,6 +158,7 @@ public class Cocos2dxEditBoxHelper {
|
||||
|
||||
@Override
|
||||
public void onFocusChange(View v, boolean hasFocus) {
|
||||
editBox.setTag(true);
|
||||
if (hasFocus) {
|
||||
mCocos2dxActivity.runOnGLThread(new Runnable() {
|
||||
@Override
|
||||
@@ -193,8 +195,11 @@ public class Cocos2dxEditBoxHelper {
|
||||
(keyCode == KeyEvent.KEYCODE_ENTER)) {
|
||||
//if editbox doesn't support multiline, just hide the keyboard
|
||||
if ((editBox.getInputType() & InputType.TYPE_TEXT_FLAG_MULTI_LINE) != InputType.TYPE_TEXT_FLAG_MULTI_LINE) {
|
||||
Cocos2dxEditBoxHelper.runEditBoxEditingReturnInGLThread(index);
|
||||
Cocos2dxEditBoxHelper.closeKeyboardOnUiThread(index);
|
||||
return true;
|
||||
} else {
|
||||
Cocos2dxEditBoxHelper.runEditBoxEditingReturnInGLThread(index);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
@@ -218,6 +223,15 @@ public class Cocos2dxEditBoxHelper {
|
||||
return mViewTag++;
|
||||
}
|
||||
|
||||
private static void runEditBoxEditingReturnInGLThread(final int index) {
|
||||
mCocos2dxActivity.runOnGLThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Cocos2dxEditBoxHelper.__editBoxEditingReturn(index);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void removeEditBox(final int index) {
|
||||
mCocos2dxActivity.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
|
||||
@@ -155,14 +155,14 @@ public:
|
||||
ScriptingCore::getInstance()->executeFunctionWithOwner(delegateVal, "editBoxTextChanged", 2, dataVal);
|
||||
}
|
||||
|
||||
virtual void editBoxReturn(EditBox* editBox) override
|
||||
virtual void editBoxEditingReturn(EditBox* editBox) override
|
||||
{
|
||||
js_proxy_t * p = jsb_get_native_proxy(editBox);
|
||||
if (!p) return;
|
||||
|
||||
jsval arg = OBJECT_TO_JSVAL(p->obj);
|
||||
JS::RootedValue delegateVal(ScriptingCore::getInstance()->getGlobalContext(), _JSDelegate);
|
||||
ScriptingCore::getInstance()->executeFunctionWithOwner(delegateVal, "editBoxReturn", 1, &arg);
|
||||
ScriptingCore::getInstance()->executeFunctionWithOwner(delegateVal, "editBoxEditingReturn", 1, &arg);
|
||||
}
|
||||
|
||||
void setJSDelegate(JS::HandleValue pJSDelegate)
|
||||
|
||||
@@ -404,20 +404,16 @@ ccui.Scale9Sprite.prototype.updateWithBatchNode = function (batchNode, originalR
|
||||
|
||||
if (ccui.WebView)
|
||||
{
|
||||
/**
|
||||
* The WebView support list of events
|
||||
* @type {{LOADING: string, LOADED: string, ERROR: string}}
|
||||
*/
|
||||
ccui.WebView.EventType = {
|
||||
LOADING: "loading",
|
||||
LOADED: "load",
|
||||
ERROR: "error",
|
||||
JS_EVALUATED: "js"
|
||||
LOADING: 0,
|
||||
LOADED: 1,
|
||||
ERROR: 2,
|
||||
JS_EVALUATED: 3
|
||||
};
|
||||
|
||||
ccui.WebView.prototype._loadURL = ccui.WebView.prototype.loadURL;
|
||||
ccui.WebView.prototype.loadURL = function (url) {
|
||||
if (url.indexOf("http://") >= 0)
|
||||
if (url.indexOf("http://") >= 0 || url.indexOf("https://") >= 0)
|
||||
{
|
||||
this._loadURL(url);
|
||||
}
|
||||
|
||||
@@ -173,7 +173,7 @@
|
||||
_editState = NO;
|
||||
if ( [[[notification userInfo] objectForKey:@"NSTextMovement"] intValue] == NSReturnTextMovement )
|
||||
{
|
||||
getEditBoxImplMac()->editBoxEditingDidBegin();
|
||||
getEditBoxImplMac()->editBoxEditingReturn();
|
||||
}
|
||||
|
||||
getEditBoxImplMac()->editBoxEditingDidEnd([self getText]);
|
||||
@@ -329,7 +329,7 @@
|
||||
}
|
||||
|
||||
if ([replacementString isEqualToString:[NSString stringWithUTF8String:"\n"]]) {
|
||||
getEditBoxImplMac()->editBoxEditingDidBegin();
|
||||
getEditBoxImplMac()->editBoxEditingReturn();
|
||||
}
|
||||
|
||||
if (affectedCharRange.length + affectedCharRange.location > textView.string.length) {
|
||||
|
||||
@@ -23,8 +23,8 @@
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#include "ui/UIEditBox/UIEditBox.h"
|
||||
#include "ui/UIEditBox/UIEditBoxImpl.h"
|
||||
#include "UIEditBox.h"
|
||||
#include "UIEditBoxImpl.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace ui {
|
||||
|
||||
static const float CHECK_EDITBOX_POSITION_INTERVAL = 0.1f;
|
||||
|
||||
EditBox::EditBox(void)
|
||||
EditBox::EditBox()
|
||||
: _editBoxImpl(nullptr)
|
||||
, _delegate(nullptr)
|
||||
, _editBoxInputMode(EditBox::InputMode::SINGLE_LINE)
|
||||
@@ -51,7 +51,7 @@ EditBox::EditBox(void)
|
||||
{
|
||||
}
|
||||
|
||||
EditBox::~EditBox(void)
|
||||
EditBox::~EditBox()
|
||||
{
|
||||
CC_SAFE_DELETE(_editBoxImpl);
|
||||
#if CC_ENABLE_SCRIPT_BINDING
|
||||
@@ -108,8 +108,8 @@ bool EditBox::initWithSizeAndBackgroundSprite(const cocos2d::Size &size, cocos2d
|
||||
{
|
||||
_editBoxImpl = __createSystemEditBox(this);
|
||||
_editBoxImpl->initWithSize(size);
|
||||
_editBoxImpl->setInputMode(EditBox::InputMode::ANY);
|
||||
|
||||
_editBoxImpl->setInputMode(EditBox::InputMode::SINGLE_LINE);
|
||||
|
||||
_backgroundSprite = pNormal9SpriteBg;
|
||||
|
||||
this->setContentSize(size);
|
||||
@@ -189,7 +189,7 @@ void EditBox::setText(const char* pText)
|
||||
}
|
||||
}
|
||||
|
||||
const char* EditBox::getText(void)
|
||||
const char* EditBox::getText()
|
||||
{
|
||||
if (_editBoxImpl != nullptr)
|
||||
{
|
||||
@@ -307,7 +307,7 @@ void EditBox::setPlaceHolder(const char* pText)
|
||||
}
|
||||
}
|
||||
|
||||
const char* EditBox::getPlaceHolder(void)
|
||||
const char* EditBox::getPlaceHolder()
|
||||
{
|
||||
return _placeHolder.c_str();
|
||||
}
|
||||
@@ -413,7 +413,7 @@ void EditBox::draw(Renderer *renderer, const Mat4 &parentTransform, uint32_t par
|
||||
}
|
||||
}
|
||||
|
||||
void EditBox::onEnter(void)
|
||||
void EditBox::onEnter()
|
||||
{
|
||||
#if CC_ENABLE_SCRIPT_BINDING
|
||||
if (_scriptType == kScriptTypeJavascript)
|
||||
@@ -441,7 +441,7 @@ void EditBox::updatePosition(float dt)
|
||||
}
|
||||
|
||||
|
||||
void EditBox::onExit(void)
|
||||
void EditBox::onExit()
|
||||
{
|
||||
#if CC_ENABLE_SCRIPT_BINDING
|
||||
if (_scriptType == kScriptTypeJavascript)
|
||||
@@ -516,7 +516,7 @@ void EditBox::registerScriptEditBoxHandler(int handler)
|
||||
_scriptEditBoxHandler = handler;
|
||||
}
|
||||
|
||||
void EditBox::unregisterScriptEditBoxHandler(void)
|
||||
void EditBox::unregisterScriptEditBoxHandler()
|
||||
{
|
||||
if (0 != _scriptEditBoxHandler)
|
||||
{
|
||||
@@ -529,3 +529,4 @@ void EditBox::unregisterScriptEditBoxHandler(void)
|
||||
}
|
||||
|
||||
NS_CC_END
|
||||
|
||||
|
||||
@@ -78,8 +78,8 @@ namespace ui {
|
||||
* This method is called when the return button was pressed or the outside area of keyboard was touched.
|
||||
* @param editBox The edit box object that generated the event.
|
||||
*/
|
||||
virtual void editBoxReturn(EditBox* editBox) = 0;
|
||||
|
||||
virtual void editBoxEditingReturn(EditBox* editBox) = 0;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -215,15 +215,15 @@ namespace ui {
|
||||
* @js ctor
|
||||
* @lua new
|
||||
*/
|
||||
EditBox(void);
|
||||
|
||||
EditBox();
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~EditBox(void);
|
||||
|
||||
virtual ~EditBox();
|
||||
|
||||
/**
|
||||
* Init edit box with specified size. This method should be invoked right after constructor.
|
||||
* @param size The size of edit box.
|
||||
@@ -290,14 +290,14 @@ namespace ui {
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
void unregisterScriptEditBoxHandler(void);
|
||||
void unregisterScriptEditBoxHandler();
|
||||
/**
|
||||
* get a script Handler
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
int getScriptEditBoxHandler(void){ return _scriptEditBoxHandler ;}
|
||||
|
||||
int getScriptEditBoxHandler(){ return _scriptEditBoxHandler ;}
|
||||
|
||||
#endif // #if CC_ENABLE_SCRIPT_BINDING
|
||||
|
||||
/**
|
||||
@@ -310,8 +310,8 @@ namespace ui {
|
||||
* Get the text entered in the edit box.
|
||||
* @return The text entered in the edit box.
|
||||
*/
|
||||
const char* getText(void);
|
||||
|
||||
const char* getText();
|
||||
|
||||
/**
|
||||
* Set the font. Only system font is allowed.
|
||||
* @param pFontName The font name.
|
||||
@@ -377,8 +377,8 @@ namespace ui {
|
||||
* Get a text in the edit box that acts as a placeholder when an
|
||||
* edit box is empty.
|
||||
*/
|
||||
const char* getPlaceHolder(void);
|
||||
|
||||
const char* getPlaceHolder();
|
||||
|
||||
/**
|
||||
* Set the input mode of the edit box.
|
||||
* @param inputMode One of the EditBox::InputMode constants.
|
||||
@@ -433,12 +433,12 @@ namespace ui {
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void onEnter(void) override;
|
||||
virtual void onEnter() override;
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void onExit(void) override;
|
||||
virtual void onExit() override;
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
|
||||
@@ -24,11 +24,11 @@
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#include "ui/UIEditBox/UIEditBoxImpl-android.h"
|
||||
#include "UIEditBoxImpl-android.h"
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
||||
|
||||
#include "ui/UIEditBox/UIEditBox.h"
|
||||
#include "UIEditBox.h"
|
||||
#include <jni.h>
|
||||
#include "platform/android/jni/JniHelper.h"
|
||||
#include "2d/CCLabel.h"
|
||||
@@ -40,14 +40,15 @@
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
static const std::string editBoxClassName = "org/cocos2dx/lib/Cocos2dxEditBoxHelper";
|
||||
#define editBoxClassName "org/cocos2dx/lib/Cocos2dxEditBoxHelper"
|
||||
|
||||
namespace ui {
|
||||
|
||||
#define LOGD(...) __android_log_print(ANDROID_LOG_ERROR,"",__VA_ARGS__)
|
||||
#define LOGD(...) __android_log_print(ANDROID_LOG_ERROR,"cocos EditBoxImplAndroid",__VA_ARGS__)
|
||||
static void editBoxEditingDidBegin(int index);
|
||||
static void editBoxEditingDidChanged(int index, const std::string& text);
|
||||
static void editBoxEditingDidEnd(int index, const std::string& text);
|
||||
static void editBoxEditingReturn(int index);
|
||||
extern "C"{
|
||||
JNIEXPORT void JNICALL Java_org_cocos2dx_lib_Cocos2dxEditBoxHelper_editBoxEditingDidBegin(JNIEnv *env, jclass, jint index) {
|
||||
editBoxEditingDidBegin(index);
|
||||
@@ -62,6 +63,10 @@ extern "C"{
|
||||
std::string textString = StringUtils::getStringUTFCharsJNI(env,text);
|
||||
editBoxEditingDidEnd(index, textString);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_cocos2dx_lib_Cocos2dxEditBoxHelper_editBoxEditingReturn(JNIEnv *env, jclass, jint index) {
|
||||
editBoxEditingReturn(index);
|
||||
}
|
||||
}
|
||||
|
||||
static std::unordered_map<int, EditBoxImplAndroid*> s_allEditBoxes;
|
||||
@@ -136,7 +141,7 @@ void EditBoxImplAndroid::setNativeFontColor(const Color4B& color)
|
||||
|
||||
void EditBoxImplAndroid::setNativePlaceholderFont(const char* pFontName, int fontSize)
|
||||
{
|
||||
CCLOG("Warning! You can't change Android Hint fontName and fontSize");
|
||||
CCLOG("Wraning! You can't change Andriod Hint fontName and fontSize");
|
||||
}
|
||||
|
||||
void EditBoxImplAndroid::setNativePlaceholderFontColor(const Color4B& color)
|
||||
@@ -235,6 +240,15 @@ void editBoxEditingDidEnd(int index, const std::string& text)
|
||||
}
|
||||
}
|
||||
|
||||
void editBoxEditingReturn(int index)
|
||||
{
|
||||
auto it = s_allEditBoxes.find(index);
|
||||
if (it != s_allEditBoxes.end())
|
||||
{
|
||||
s_allEditBoxes[index]->editBoxEditingReturn();
|
||||
}
|
||||
}
|
||||
|
||||
const char* EditBoxImplAndroid::getNativeDefaultFontName()
|
||||
{
|
||||
return "sans-serif";
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
||||
|
||||
#include "ui/UIEditBox/UIEditBoxImpl-common.h"
|
||||
#include "UIEditBoxImpl-common.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
@@ -70,7 +70,7 @@ public:
|
||||
virtual const char* getNativeDefaultFontName() override;
|
||||
virtual void nativeOpenKeyboard() override;
|
||||
virtual void nativeCloseKeyboard() override;
|
||||
virtual void setNativeMaxLength(int maxLength) override;
|
||||
virtual void setNativeMaxLength(int maxLength);
|
||||
|
||||
private:
|
||||
int _editBoxIndex;
|
||||
|
||||
@@ -23,18 +23,17 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
#include "ui/UIEditBox/UIEditBoxImpl-common.h"
|
||||
#include "UIEditBoxImpl-common.h"
|
||||
|
||||
#define kLabelZOrder 9999
|
||||
|
||||
#include "ui/UIEditBox/UIEditBox.h"
|
||||
#include "UIEditBox.h"
|
||||
#include "base/CCDirector.h"
|
||||
#include "2d/CCLabel.h"
|
||||
#include "ui/UIHelper.h"
|
||||
|
||||
static const int CC_EDIT_BOX_PADDING = 5;
|
||||
|
||||
#define PASSWORD_CHAR "\u25CF"
|
||||
NS_CC_BEGIN
|
||||
|
||||
namespace ui {
|
||||
@@ -80,13 +79,14 @@ void EditBoxImplCommon::initInactiveLabels(const Size& size)
|
||||
const char* pDefaultFontName = this->getNativeDefaultFontName();
|
||||
|
||||
_label = Label::create();
|
||||
_label->setAnchorPoint(Vec2(0, 0.5f));
|
||||
_label->setAnchorPoint(Vec2(0,1));
|
||||
_label->setOverflow(Label::Overflow::CLAMP);
|
||||
_label->setColor(Color3B::WHITE);
|
||||
_label->setVisible(false);
|
||||
_editBox->addChild(_label, kLabelZOrder);
|
||||
|
||||
_labelPlaceHolder = Label::create();
|
||||
_labelPlaceHolder->setAnchorPoint(Vec2(0, 0.5f));
|
||||
_labelPlaceHolder->setAnchorPoint(Vec2(0,1));
|
||||
_labelPlaceHolder->setColor(Color3B::GRAY);
|
||||
_editBox->addChild(_labelPlaceHolder, kLabelZOrder);
|
||||
|
||||
@@ -95,10 +95,29 @@ void EditBoxImplCommon::initInactiveLabels(const Size& size)
|
||||
|
||||
}
|
||||
|
||||
void EditBoxImplCommon::placeInactiveLabels()
|
||||
void EditBoxImplCommon::placeInactiveLabels(const Size& size)
|
||||
{
|
||||
_label->setPosition(CC_EDIT_BOX_PADDING, _contentSize.height / 2.0f);
|
||||
_labelPlaceHolder->setPosition(CC_EDIT_BOX_PADDING, _contentSize.height / 2.0f);
|
||||
_label->setDimensions(size.width, size.height);
|
||||
|
||||
auto placeholderSize = _labelPlaceHolder->getContentSize();
|
||||
|
||||
if(_editBoxInputMode == EditBox::InputMode::ANY){
|
||||
_label->setPosition(Vec2(CC_EDIT_BOX_PADDING, size.height - CC_EDIT_BOX_PADDING));
|
||||
_label->setVerticalAlignment(TextVAlignment::TOP);
|
||||
_label->enableWrap(true);
|
||||
|
||||
_labelPlaceHolder->setPosition(Vec2(CC_EDIT_BOX_PADDING, size.height - CC_EDIT_BOX_PADDING));
|
||||
_labelPlaceHolder->setVerticalAlignment(TextVAlignment::TOP);
|
||||
}
|
||||
else {
|
||||
_label->enableWrap(false);
|
||||
_label->setPosition(Vec2(CC_EDIT_BOX_PADDING, size.height));
|
||||
_label->setVerticalAlignment(TextVAlignment::CENTER);
|
||||
|
||||
_labelPlaceHolder->setPosition(Vec2(CC_EDIT_BOX_PADDING,
|
||||
(size.height + placeholderSize.height) / 2));
|
||||
_labelPlaceHolder->setVerticalAlignment(TextVAlignment::CENTER);
|
||||
}
|
||||
}
|
||||
|
||||
void EditBoxImplCommon::setInactiveText(const char* pText)
|
||||
@@ -106,8 +125,8 @@ void EditBoxImplCommon::setInactiveText(const char* pText)
|
||||
if(EditBox::InputFlag::PASSWORD == _editBoxInputFlag)
|
||||
{
|
||||
std::string passwordString;
|
||||
for(size_t i = 0; i < strlen(pText); ++i)
|
||||
passwordString.append(PASSWORD_CHAR);
|
||||
for(int i = 0; i < strlen(pText); ++i)
|
||||
passwordString.append("\u25CF");
|
||||
_label->setString(passwordString);
|
||||
}
|
||||
else
|
||||
@@ -170,6 +189,7 @@ void EditBoxImplCommon::setInputMode(EditBox::InputMode inputMode)
|
||||
{
|
||||
_editBoxInputMode = inputMode;
|
||||
this->setNativeInputMode(inputMode);
|
||||
this->placeInactiveLabels(_editBox->getContentSize());
|
||||
}
|
||||
|
||||
void EditBoxImplCommon::setMaxLength(int maxLength)
|
||||
@@ -217,7 +237,7 @@ void EditBoxImplCommon::setText(const char* text)
|
||||
refreshInactiveText();
|
||||
}
|
||||
|
||||
const char* EditBoxImplCommon::getText(void)
|
||||
const char* EditBoxImplCommon::getText()
|
||||
{
|
||||
return _text.c_str();
|
||||
}
|
||||
@@ -251,7 +271,7 @@ void EditBoxImplCommon::setContentSize(const Size& size)
|
||||
{
|
||||
_contentSize = size;
|
||||
CCLOG("[Edit text] content size = (%f, %f)", size.width, size.height);
|
||||
placeInactiveLabels();
|
||||
placeInactiveLabels(size);
|
||||
}
|
||||
|
||||
void EditBoxImplCommon::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
|
||||
@@ -263,7 +283,7 @@ void EditBoxImplCommon::draw(Renderer *renderer, const Mat4 &transform, uint32_t
|
||||
}
|
||||
}
|
||||
|
||||
void EditBoxImplCommon::onEnter(void)
|
||||
void EditBoxImplCommon::onEnter()
|
||||
{
|
||||
const char* pText = getText();
|
||||
if (pText) {
|
||||
@@ -318,7 +338,6 @@ void EditBoxImplCommon::editBoxEditingDidEnd(const std::string& text)
|
||||
if (pDelegate != nullptr)
|
||||
{
|
||||
pDelegate->editBoxEditingDidEnd(_editBox);
|
||||
pDelegate->editBoxReturn(_editBox);
|
||||
}
|
||||
|
||||
#if CC_ENABLE_SCRIPT_BINDING
|
||||
@@ -351,7 +370,7 @@ void EditBoxImplCommon::editBoxEditingChanged(const std::string& text)
|
||||
}
|
||||
|
||||
#if CC_ENABLE_SCRIPT_BINDING
|
||||
if (nullptr != _editBox && 0 != _editBox->getScriptEditBoxHandler())
|
||||
if (NULL != _editBox && 0 != _editBox->getScriptEditBoxHandler())
|
||||
{
|
||||
cocos2d::CommonScriptData data(_editBox->getScriptEditBoxHandler(), "changed", _editBox);
|
||||
cocos2d::ScriptEvent event(cocos2d::kCommonEvent, (void *)&data);
|
||||
@@ -359,6 +378,15 @@ void EditBoxImplCommon::editBoxEditingChanged(const std::string& text)
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void EditBoxImplCommon::editBoxEditingReturn()
|
||||
{
|
||||
cocos2d::ui::EditBoxDelegate *pDelegate = _editBox->getDelegate();
|
||||
if (pDelegate != nullptr)
|
||||
{
|
||||
pDelegate->editBoxEditingReturn(_editBox);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -28,8 +28,8 @@
|
||||
#define __UIEditBoxIMPLICOMMON_H__
|
||||
|
||||
#include "platform/CCPlatformConfig.h"
|
||||
#include "ui/UIEditBox/UIEditBoxImpl-common.h"
|
||||
#include "ui/UIEditBox/UIEditBoxImpl.h"
|
||||
|
||||
#include "UIEditBoxImpl.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
@@ -66,8 +66,8 @@ public:
|
||||
|
||||
virtual void setMaxLength(int maxLength) override;
|
||||
virtual int getMaxLength() override;
|
||||
|
||||
virtual const char* getText(void) override;
|
||||
|
||||
virtual const char* getText() override;
|
||||
virtual void refreshInactiveText();
|
||||
|
||||
virtual void setContentSize(const Size& size) override;
|
||||
@@ -84,7 +84,7 @@ public:
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void onEnter(void) override;
|
||||
virtual void onEnter() override;
|
||||
virtual void openKeyboard() override;
|
||||
virtual void closeKeyboard() override;
|
||||
|
||||
@@ -93,7 +93,8 @@ public:
|
||||
void editBoxEditingDidBegin();
|
||||
void editBoxEditingChanged(const std::string& text);
|
||||
void editBoxEditingDidEnd(const std::string& text);
|
||||
|
||||
void editBoxEditingReturn();
|
||||
|
||||
virtual bool isEditing() override = 0;
|
||||
virtual void createNativeControl(const Rect& frame) = 0;
|
||||
virtual void setNativeFont(const char* pFontName, int fontSize) = 0;
|
||||
@@ -114,11 +115,10 @@ public:
|
||||
|
||||
|
||||
private:
|
||||
void initInactiveLabels(const Size& size);
|
||||
void setInactiveText(const char* pText);
|
||||
void placeInactiveLabels();
|
||||
void initInactiveLabels(const Size& size);
|
||||
void setInactiveText(const char* pText);
|
||||
void placeInactiveLabels(const Size& size);
|
||||
virtual void doAnimationWhenKeyboardMove(float duration, float distance)override {};
|
||||
|
||||
Label* _label;
|
||||
Label* _labelPlaceHolder;
|
||||
EditBox::InputMode _editBoxInputMode;
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
|
||||
|
||||
#include "ui/UIEditBox/UIEditBoxImpl-common.h"
|
||||
#include "UIEditBoxImpl-common.h"
|
||||
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ public:
|
||||
virtual void nativeCloseKeyboard() override;
|
||||
|
||||
//need to remove siri text
|
||||
virtual const char* getText(void)override;
|
||||
virtual const char* getText()override;
|
||||
|
||||
virtual void doAnimationWhenKeyboardMove(float duration, float distance) override;
|
||||
private:
|
||||
|
||||
@@ -23,13 +23,13 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
#include "ui/UIEditBox/UIEditBoxImpl-ios.h"
|
||||
#include "UIEditBoxImpl-ios.h"
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
|
||||
|
||||
#define kLabelZOrder 9999
|
||||
|
||||
#include "ui/UIEditBox/UIEditBox.h"
|
||||
#include "UIEditBox.h"
|
||||
#include "base/CCDirector.h"
|
||||
#include "2d/CCLabel.h"
|
||||
#import "platform/ios/CCEAGLView-ios.h"
|
||||
@@ -37,7 +37,7 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
#import "ui/UIEditBox/iOS/CCUIEditBoxIOS.h"
|
||||
#import "iOS/CCUIEditBoxIOS.h"
|
||||
|
||||
#define getEditBoxImplIOS() ((cocos2d::ui::EditBoxImplIOS *)_editBox)
|
||||
|
||||
@@ -142,7 +142,7 @@ NSString* removeSiriString(NSString* str)
|
||||
return [str stringByReplacingOccurrencesOfString:siriString withString:@""];
|
||||
}
|
||||
|
||||
const char* EditBoxImplIOS::getText(void)
|
||||
const char* EditBoxImplIOS::getText()
|
||||
{
|
||||
return [removeSiriString(_systemControl.text) UTF8String];
|
||||
}
|
||||
@@ -209,7 +209,7 @@ UIFont* EditBoxImplIOS::constructFont(const char *fontName, int fontSize)
|
||||
float retinaFactor = eaglview.contentScaleFactor;
|
||||
NSString * fntName = [NSString stringWithUTF8String:fontName];
|
||||
fntName = [[fntName lastPathComponent] stringByDeletingPathExtension];
|
||||
|
||||
|
||||
auto glview = cocos2d::Director::getInstance()->getOpenGLView();
|
||||
float scaleFactor = glview->getScaleX();
|
||||
|
||||
|
||||
@@ -28,8 +28,8 @@
|
||||
|
||||
#include "ui/UIEditBox/UIEditBoxImpl-mac.h"
|
||||
#include "base/CCDirector.h"
|
||||
#include "UIEditBox.h"
|
||||
#include "base/ccUTF8.h"
|
||||
#include "ui/UIEditBox/UIEditBox.h"
|
||||
#include "ui/UIEditBox/Mac/CCUIEditBoxMac.h"
|
||||
NS_CC_BEGIN
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "ui/UIEditBox/UIEditBox.h"
|
||||
#include "UIEditBox.h"
|
||||
|
||||
#if (CC_TARGET_PLATFORM != CC_PLATFORM_ANDROID ) && (CC_TARGET_PLATFORM != CC_PLATFORM_IOS ) && (CC_TARGET_PLATFORM != CC_PLATFORM_WIN32) && (CC_TARGET_PLATFORM != CC_PLATFORM_MAC) && (CC_TARGET_PLATFORM != CC_PLATFORM_TIZEN) && (CC_TARGET_PLATFORM != CC_PLATFORM_WINRT) && (CC_TARGET_PLATFORM != CC_PLATFORM_WP8)
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace ui {
|
||||
|
||||
EditBoxImpl* __createSystemEditBox(EditBox* pEditBox)
|
||||
{
|
||||
return nullptr;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -16,3 +16,4 @@ EditBoxImpl* __createSystemEditBox(EditBox* pEditBox)
|
||||
NS_CC_END
|
||||
|
||||
#endif /* #if (..) */
|
||||
|
||||
|
||||
@@ -22,12 +22,12 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
#include "ui/UIEditBox/UIEditBoxImpl-win32.h"
|
||||
#include "UIEditBoxImpl-win32.h"
|
||||
|
||||
#include "platform/CCPlatformConfig.h"
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
|
||||
|
||||
#include "ui/UIEditBox/UIEditBox.h"
|
||||
#include "UIEditBox.h"
|
||||
#include <windows.h>
|
||||
#include <tchar.h>
|
||||
#include <stdio.h>
|
||||
@@ -487,7 +487,7 @@ void CWin32InputBox::InitDialog()
|
||||
default:
|
||||
break;
|
||||
}
|
||||
CCASSERT(_getMsgHook == nullptr, "Windows Message hook already set");
|
||||
CCASSERT(_getMsgHook == NULL, "Windows Message hook already set");
|
||||
|
||||
// To make the enter key work, here need a Windows Message hook.
|
||||
// Please refer to https://support.microsoft.com/en-us/kb/187988
|
||||
@@ -803,7 +803,7 @@ void EditBoxImplWin::setText(const char* pText)
|
||||
}
|
||||
}
|
||||
|
||||
const char* EditBoxImplWin::getText(void)
|
||||
const char* EditBoxImplWin::getText()
|
||||
{
|
||||
return _text.c_str();
|
||||
}
|
||||
@@ -860,11 +860,11 @@ void EditBoxImplWin::openKeyboard()
|
||||
_isEditing = true;
|
||||
#if CC_ENABLE_SCRIPT_BINDING
|
||||
auto editBox = this->getEditBox();
|
||||
if (nullptr != editBox && 0 != editBox->getScriptEditBoxHandler())
|
||||
if (nullptr != editBox && 0 != editBox->getScriptEditBoxHandler() && ScriptEngineManager::ShareInstance)
|
||||
{
|
||||
CommonScriptData data(editBox->getScriptEditBoxHandler(), "began", editBox);
|
||||
ScriptEvent event(kCommonEvent, (void*)&data);
|
||||
ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event);
|
||||
CommonScriptData data(editBox->getScriptEditBoxHandler(), "began",editBox);
|
||||
ScriptEvent event(kCommonEvent,(void*)&data);
|
||||
ScriptEngineManager::ShareInstance->getScriptEngine()->sendEvent(&event);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -894,23 +894,23 @@ void EditBoxImplWin::onWin32InputBoxClose(INT_PTR buttonId)
|
||||
{
|
||||
_delegate->editBoxTextChanged(_editBox, getText());
|
||||
_delegate->editBoxEditingDidEnd(_editBox);
|
||||
_delegate->editBoxReturn(_editBox);
|
||||
_delegate->editBoxEditingReturn(_editBox);
|
||||
}
|
||||
|
||||
#if CC_ENABLE_SCRIPT_BINDING
|
||||
if (nullptr != _editBox && 0 != _editBox->getScriptEditBoxHandler())
|
||||
if (nullptr != _editBox && 0 != _editBox->getScriptEditBoxHandler() && ScriptEngineManager::ShareInstance)
|
||||
{
|
||||
CommonScriptData data(_editBox->getScriptEditBoxHandler(), "changed",_editBox);
|
||||
ScriptEvent event(kCommonEvent,(void*)&data);
|
||||
ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event);
|
||||
ScriptEngineManager::ShareInstance->getScriptEngine()->sendEvent(&event);
|
||||
memset(data.eventName,0,sizeof(data.eventName));
|
||||
strncpy(data.eventName,"ended",sizeof(data.eventName));
|
||||
event.data = (void*)&data;
|
||||
ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event);
|
||||
ScriptEngineManager::ShareInstance->getScriptEngine()->sendEvent(&event);
|
||||
memset(data.eventName,0,sizeof(data.eventName));
|
||||
strncpy(data.eventName,"return",sizeof(data.eventName));
|
||||
event.data = (void*)&data;
|
||||
ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event);
|
||||
ScriptEngineManager::ShareInstance->getScriptEngine()->sendEvent(&event);
|
||||
}
|
||||
#endif // #if CC_ENABLE_SCRIPT_BINDING
|
||||
}
|
||||
@@ -931,7 +931,7 @@ void EditBoxImplWin::onWin32InputBoxTextChange(const char *pText)
|
||||
{
|
||||
CommonScriptData data(_editBox->getScriptEditBoxHandler(), "changed", _editBox);
|
||||
ScriptEvent event(kCommonEvent, (void*)&data);
|
||||
ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event);
|
||||
ScriptEngineManager::ShareInstance->getScriptEngine()->sendEvent(&event);
|
||||
}
|
||||
#endif // #if CC_ENABLE_SCRIPT_BINDING
|
||||
}
|
||||
@@ -947,7 +947,7 @@ void EditBoxImplWin::closeKeyboard()
|
||||
}
|
||||
}
|
||||
|
||||
void EditBoxImplWin::onEnter(void)
|
||||
void EditBoxImplWin::onEnter()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
|
||||
|
||||
#include "ui/UIEditBox/UIEditBoxImpl.h"
|
||||
#include "UIEditBoxImpl.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
@@ -64,7 +64,7 @@ public:
|
||||
virtual bool isEditing();
|
||||
|
||||
virtual void setText(const char* pText);
|
||||
virtual const char* getText(void);
|
||||
virtual const char* getText();
|
||||
virtual void setPlaceHolder(const char* pText);
|
||||
virtual void setPosition(const Vec2& pos);
|
||||
virtual void setVisible(bool visible);
|
||||
@@ -82,7 +82,7 @@ public:
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void onEnter(void);
|
||||
virtual void onEnter();
|
||||
private:
|
||||
|
||||
Label* _label;
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#ifndef __UIEditBoxIMPL_H__
|
||||
#define __UIEditBoxIMPL_H__
|
||||
|
||||
#include "ui/UIEditBox/UIEditBox.h"
|
||||
#include "UIEditBox.h"
|
||||
|
||||
|
||||
namespace cocos2d {
|
||||
@@ -58,7 +58,7 @@ namespace cocos2d {
|
||||
virtual bool isEditing() = 0;
|
||||
|
||||
virtual void setText(const char* pText) = 0;
|
||||
virtual const char* getText(void) = 0;
|
||||
virtual const char* getText() = 0;
|
||||
virtual void setPlaceHolder(const char* pText) = 0;
|
||||
virtual void doAnimationWhenKeyboardMove(float duration, float distance) = 0;
|
||||
|
||||
@@ -83,7 +83,7 @@ namespace cocos2d {
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void onEnter(void) = 0;
|
||||
virtual void onEnter() = 0;
|
||||
|
||||
|
||||
void setDelegate(EditBoxDelegate* pDelegate) { _delegate = pDelegate; };
|
||||
@@ -101,3 +101,4 @@ namespace cocos2d {
|
||||
}
|
||||
|
||||
#endif /* __UIEditBoxIMPL_H__ */
|
||||
|
||||
|
||||
@@ -26,8 +26,8 @@
|
||||
****************************************************************************/
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "ui/UIEditBox/iOS/CCUITextInput.h"
|
||||
#include "ui/UIEditBox/UIEditBoxImpl-ios.h"
|
||||
#import "CCUITextInput.h"
|
||||
#include "UIEditBoxImpl-ios.h"
|
||||
|
||||
|
||||
@interface UIEditBoxImplIOS_objc : NSObject <UITextFieldDelegate, UITextViewDelegate>
|
||||
|
||||
@@ -25,9 +25,9 @@
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#import "ui/UIEditBox/iOS/CCUIEditBoxIOS.h"
|
||||
#import "ui/UIEditBox/iOS/CCUISingleLineTextField.h"
|
||||
#import "ui/UIEditBox/iOS/CCUIMultilineTextField.h"
|
||||
#import "CCUIEditBoxIOS.h"
|
||||
#import "CCUISingleLineTextField.h"
|
||||
#import "CCUIMultilineTextField.h"
|
||||
|
||||
#import "platform/ios/CCEAGLView-ios.h"
|
||||
#include "base/CCDirector.h"
|
||||
@@ -204,6 +204,7 @@
|
||||
|
||||
case cocos2d::ui::EditBox::InputFlag::SENSITIVE:
|
||||
self.textInput.autocorrectionType = UITextAutocorrectionTypeNo;
|
||||
self.textInput.autocapitalizationType = UITextAutocapitalizationTypeNone;
|
||||
break;
|
||||
|
||||
case cocos2d::ui::EditBox::InputFlag::LOWERCASE_ALL_CHARACTERS:
|
||||
@@ -304,6 +305,7 @@
|
||||
|
||||
- (BOOL)textFieldShouldReturn:(UITextField *)sender
|
||||
{
|
||||
getEditBoxImplIOS()->editBoxEditingReturn();
|
||||
if (sender == self.textInput) {
|
||||
[sender resignFirstResponder];
|
||||
}
|
||||
@@ -325,7 +327,7 @@
|
||||
{
|
||||
CCLOG("textFieldShouldBeginEditing...");
|
||||
_editState = YES;
|
||||
|
||||
|
||||
auto view = cocos2d::Director::getInstance()->getOpenGLView();
|
||||
CCEAGLView *eaglview = (CCEAGLView *) view->getEAGLView();
|
||||
|
||||
@@ -357,6 +359,10 @@
|
||||
return YES;
|
||||
}
|
||||
|
||||
if ([text isEqualToString:[NSString stringWithUTF8String:"\n"]]) {
|
||||
getEditBoxImplIOS()->editBoxEditingReturn();
|
||||
}
|
||||
|
||||
// Prevent crashing undo bug http://stackoverflow.com/questions/433337/set-the-maximum-character-length-of-a-uitextfield
|
||||
if (range.length + range.location > textView.text.length) {
|
||||
return NO;
|
||||
@@ -406,7 +412,7 @@
|
||||
{
|
||||
CCLOG("textFieldShouldBeginEditing...");
|
||||
_editState = YES;
|
||||
|
||||
|
||||
auto view = cocos2d::Director::getInstance()->getOpenGLView();
|
||||
CCEAGLView *eaglview = (CCEAGLView *)view->getEAGLView();
|
||||
|
||||
@@ -458,3 +464,4 @@
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "ui/UIEditBox/iOS/UITextView+CCUITextInput.h"
|
||||
#import "UITextView+CCUITextInput.h"
|
||||
|
||||
#pragma mark - UIMultilineTextField implementation
|
||||
|
||||
@@ -35,3 +35,4 @@
|
||||
@property (nonatomic, retain) UILabel *placeHolderLabel;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#import "ui/UIEditBox/iOS/CCUIMultilineTextField.h"
|
||||
#import "CCUIMultilineTextField.h"
|
||||
|
||||
#include "base/CCDirector.h"
|
||||
|
||||
@@ -82,8 +82,13 @@ CGFloat const UI_PLACEHOLDER_TEXT_CHANGED_ANIMATION_DURATION = 0.25;
|
||||
- (UILabel *)placeHolderLabel
|
||||
{
|
||||
if (_placeHolderLabel == nil) {
|
||||
|
||||
_placeHolderLabel = [[UILabel alloc] initWithFrame:CGRectMake(8,8,self.bounds.size.width - 16,0)];
|
||||
auto glview = cocos2d::Director::getInstance()->getOpenGLView();
|
||||
float padding = CC_EDIT_BOX_PADDING * glview->getScaleX() / glview->getContentScaleFactor();
|
||||
|
||||
_placeHolderLabel = [[UILabel alloc] initWithFrame:CGRectMake(padding,
|
||||
padding,
|
||||
self.bounds.size.width - padding * 2,
|
||||
0)];
|
||||
_placeHolderLabel.lineBreakMode = NSLineBreakByWordWrapping;
|
||||
_placeHolderLabel.numberOfLines = 0;
|
||||
_placeHolderLabel.font = self.font;
|
||||
@@ -102,7 +107,7 @@ CGFloat const UI_PLACEHOLDER_TEXT_CHANGED_ANIMATION_DURATION = 0.25;
|
||||
- (CGRect)textRectForBounds:(CGRect)bounds
|
||||
{
|
||||
auto glview = cocos2d::Director::getInstance()->getOpenGLView();
|
||||
|
||||
|
||||
float padding = CC_EDIT_BOX_PADDING * glview->getScaleX() / glview->getContentScaleFactor();
|
||||
return CGRectInset(bounds, padding, padding);
|
||||
}
|
||||
@@ -146,3 +151,4 @@ CGFloat const UI_PLACEHOLDER_TEXT_CHANGED_ANIMATION_DURATION = 0.25;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@@ -25,9 +25,10 @@
|
||||
****************************************************************************/
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "ui/UIEditBox/iOS/UITextField+CCUITextInput.h"
|
||||
#import "UITextField+CCUITextInput.h"
|
||||
|
||||
/** TODO: Missing doc - Why is this subclass necessary?
|
||||
*/
|
||||
@interface CCUISingleLineTextField : UITextField
|
||||
@end
|
||||
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#import "ui/UIEditBox/iOS/CCUISingleLineTextField.h"
|
||||
#import "ui/UIEditBox/iOS/CCUITextInput.h"
|
||||
#import "CCUISingleLineTextField.h"
|
||||
#import "CCUITextInput.h"
|
||||
|
||||
#include "base/CCDirector.h"
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
- (CGRect)textRectForBounds:(CGRect)bounds
|
||||
{
|
||||
auto glview = cocos2d::Director::getInstance()->getOpenGLView();
|
||||
|
||||
|
||||
float padding = CC_EDIT_BOX_PADDING * glview->getScaleX() / glview->getContentScaleFactor();
|
||||
return CGRectInset(bounds, padding, padding);
|
||||
}
|
||||
@@ -46,3 +46,4 @@
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "ui/UIEditBox/iOS/CCUITextInput.h"
|
||||
#import "CCUITextInput.h"
|
||||
|
||||
|
||||
@interface UITextField (CCUITextInput) <CCUITextInput>
|
||||
@@ -34,3 +34,4 @@
|
||||
* http://stackoverflow.com/questions/2567498/objective-c-categories-in-static-library
|
||||
*/
|
||||
extern void LoadUITextFieldCCUITextInputCategory();
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#import "ui/UIEditBox/iOS/UITextField+CCUITextInput.h"
|
||||
#import "UITextField+CCUITextInput.h"
|
||||
|
||||
@implementation UITextField (CCUITextInput)
|
||||
|
||||
@@ -87,3 +87,4 @@
|
||||
void LoadUITextFieldCCUITextInputCategory() {
|
||||
// noop
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "ui/UIEditBox/iOS/CCUITextInput.h"
|
||||
#import "CCUITextInput.h"
|
||||
|
||||
|
||||
@interface UITextView (CCUITextInput) <CCUITextInput>
|
||||
@@ -34,3 +34,4 @@
|
||||
* http://stackoverflow.com/questions/2567498/objective-c-categories-in-static-library
|
||||
*/
|
||||
extern void LoadUITextViewCCUITextInputCategory();
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#import "ui/UIEditBox/iOS/UITextView+CCUITextInput.h"
|
||||
#import "UITextView+CCUITextInput.h"
|
||||
|
||||
|
||||
@implementation UITextView (CCUITextInput)
|
||||
@@ -95,3 +95,4 @@
|
||||
void LoadUITextViewCCUITextInputCategory() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user