mirror of https://github.com/axmolengine/axmol.git
Partial cursor support for text field with system font (#18555)
* Partial cursor support for text field with system font Enables cursor support without cursor blinking an zero with of cursor symbol. In case of system font usage magical "/b" symbol won't be used, also update won't be scheduled. * Update CCTextFieldTTF.cpp
This commit is contained in:
parent
4c0361e184
commit
f0a28d261b
|
@ -566,6 +566,7 @@ void TextFieldTTF::makeStringSupportCursor(std::string& displayText)
|
||||||
if (displayText.empty())
|
if (displayText.empty())
|
||||||
{
|
{
|
||||||
// \b - Next char not change x position
|
// \b - Next char not change x position
|
||||||
|
if (_currentLabelType == LabelType::TTF)
|
||||||
displayText.push_back((char) TextFormatter::NextCharNoChangeX);
|
displayText.push_back((char) TextFormatter::NextCharNoChangeX);
|
||||||
displayText.push_back(_cursorChar);
|
displayText.push_back(_cursorChar);
|
||||||
}
|
}
|
||||||
|
@ -581,6 +582,7 @@ void TextFieldTTF::makeStringSupportCursor(std::string& displayText)
|
||||||
}
|
}
|
||||||
std::string cursorChar;
|
std::string cursorChar;
|
||||||
// \b - Next char not change x position
|
// \b - Next char not change x position
|
||||||
|
if (_currentLabelType == LabelType::TTF)
|
||||||
cursorChar.push_back((char)TextFormatter::NextCharNoChangeX);
|
cursorChar.push_back((char)TextFormatter::NextCharNoChangeX);
|
||||||
cursorChar.push_back(_cursorChar);
|
cursorChar.push_back(_cursorChar);
|
||||||
stringUTF8.insert(_cursorPosition, cursorChar);
|
stringUTF8.insert(_cursorPosition, cursorChar);
|
||||||
|
@ -678,8 +680,6 @@ const std::string& TextFieldTTF::getPlaceHolder() const
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextFieldTTF::setCursorEnabled(bool enabled)
|
void TextFieldTTF::setCursorEnabled(bool enabled)
|
||||||
{
|
|
||||||
if (_currentLabelType == LabelType::TTF)
|
|
||||||
{
|
{
|
||||||
if (_cursorEnabled != enabled)
|
if (_cursorEnabled != enabled)
|
||||||
{
|
{
|
||||||
|
@ -687,22 +687,17 @@ void TextFieldTTF::setCursorEnabled(bool enabled)
|
||||||
if (_cursorEnabled)
|
if (_cursorEnabled)
|
||||||
{
|
{
|
||||||
_cursorPosition = _charCount;
|
_cursorPosition = _charCount;
|
||||||
|
if (_currentLabelType == LabelType::TTF)
|
||||||
scheduleUpdate();
|
scheduleUpdate();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_cursorPosition = 0;
|
_cursorPosition = 0;
|
||||||
|
if (_currentLabelType == LabelType::TTF)
|
||||||
unscheduleUpdate();
|
unscheduleUpdate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
CCLOG("TextFieldTTF cursor worked only LabelType::TTF");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// secureTextEntry
|
// secureTextEntry
|
||||||
void TextFieldTTF::setSecureTextEntry(bool value)
|
void TextFieldTTF::setSecureTextEntry(bool value)
|
||||||
|
|
Loading…
Reference in New Issue