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,7 +566,8 @@ 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
|
||||||
displayText.push_back((char)TextFormatter::NextCharNoChangeX);
|
if (_currentLabelType == LabelType::TTF)
|
||||||
|
displayText.push_back((char) TextFormatter::NextCharNoChangeX);
|
||||||
displayText.push_back(_cursorChar);
|
displayText.push_back(_cursorChar);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -581,7 +582,8 @@ 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
|
||||||
cursorChar.push_back((char)TextFormatter::NextCharNoChangeX);
|
if (_currentLabelType == LabelType::TTF)
|
||||||
|
cursorChar.push_back((char)TextFormatter::NextCharNoChangeX);
|
||||||
cursorChar.push_back(_cursorChar);
|
cursorChar.push_back(_cursorChar);
|
||||||
stringUTF8.insert(_cursorPosition, cursorChar);
|
stringUTF8.insert(_cursorPosition, cursorChar);
|
||||||
|
|
||||||
|
@ -679,28 +681,21 @@ 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)
|
_cursorEnabled = enabled;
|
||||||
|
if (_cursorEnabled)
|
||||||
{
|
{
|
||||||
_cursorEnabled = enabled;
|
_cursorPosition = _charCount;
|
||||||
if (_cursorEnabled)
|
if (_currentLabelType == LabelType::TTF)
|
||||||
{
|
|
||||||
_cursorPosition = _charCount;
|
|
||||||
|
|
||||||
scheduleUpdate();
|
scheduleUpdate();
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_cursorPosition = 0;
|
|
||||||
|
|
||||||
unscheduleUpdate();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
else
|
{
|
||||||
{
|
_cursorPosition = 0;
|
||||||
CCLOG("TextFieldTTF cursor worked only LabelType::TTF");
|
if (_currentLabelType == LabelType::TTF)
|
||||||
|
unscheduleUpdate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue