application.Render();
field.SetProperty(TextField::Property::TEXT, "Hello");
+ field.SetProperty(TextField::Property::PLACEHOLDER_TEXT, "Placeholder text");
field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
application.SendNotification();
application.Render();
+ for(unsigned int index = 0u; index < 6u; ++index)
+ {
+ application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+ application.SendNotification();
+ application.Render();
+ }
map[HiddenInput::Property::MODE] = HiddenInput::Mode::HIDE_ALL;
map[HiddenInput::Property::SUBSTITUTE_CHARACTER] = 0x23;
Vector<Character>& srcCharacters = impl.mModel->mLogicalModel->mText;
Vector<Character> displayCharacters;
bool useHiddenText = false;
- if(impl.mHiddenInput && impl.mEventData != nullptr && !impl.mEventData->mIsShowingPlaceholderText)
+ if(impl.mHiddenInput && impl.mEventData != nullptr)
{
- impl.mHiddenInput->Substitute(srcCharacters, displayCharacters);
- useHiddenText = true;
+ if(impl.mEventData->mIsShowingPlaceholderText)
+ {
+ impl.mHiddenInput->InitPreviousTextCount();
+ }
+ else
+ {
+ impl.mHiddenInput->Substitute(srcCharacters, displayCharacters, impl.mEventData->mPrimaryCursorPosition);
+ useHiddenText = true;
+ }
}
Vector<Character>& utf32Characters = useHiddenText ? displayCharacters : srcCharacters;
mSubstituteText(STAR),
mDisplayDuration(DEFAULT_SHOW_DURATION),
mSubstituteCount(0),
- mPreviousTextCount(0)
+ mPreviousTextCount(0u),
+ mIsLastCharacterShow(false)
{
mTimer = Timer::New(mDisplayDuration);
mTimer.TickSignal().Connect(this, &HiddenText::OnTick);
map[Toolkit::HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION] = mDisplayDuration;
}
-void HiddenText::Substitute(const Vector<Character>& source, Vector<Character>& destination)
+void HiddenText::Substitute(const Vector<Character>& source, Vector<Character>& destination, Length cursorPos)
{
const Length characterCount = source.Count();
}
case Toolkit::HiddenInput::Mode::SHOW_LAST_CHARACTER:
{
+ hideStart = begin;
+ hideEnd = end;
if(mPreviousTextCount < characterCount)
{
- hideStart = begin;
- hideEnd = end - 1;
if(mDisplayDuration > 0)
{
mTimer.SetInterval(mDisplayDuration);
mTimer.Start();
+ mIsLastCharacterShow = true;
}
else
{
}
else
{
- hideStart = begin;
- hideEnd = end;
+ mIsLastCharacterShow = false;
}
break;
}
}
- for(; begin < end; ++begin)
+
+
+ if(mHideMode == Toolkit::HiddenInput::Mode::SHOW_LAST_CHARACTER)
{
- if(begin >= hideStart && begin < hideEnd)
+ Length currentPos = 0u;
+ for(; begin < end; ++begin)
{
- *begin = static_cast<uint32_t>(mSubstituteText);
+ if(begin >= hideStart && begin < hideEnd && cursorPos > 0u && currentPos != cursorPos - 1u)
+ {
+ *begin = static_cast<uint32_t>(mSubstituteText);
+ }
+ else
+ {
+ *begin = mIsLastCharacterShow ? *sourcePos : static_cast<uint32_t>(mSubstituteText);
+ }
sourcePos++;
+ currentPos++;
}
- else
+ }
+ else
+ {
+ for(; begin < end; ++begin)
{
- *begin = *sourcePos++;
+ if(begin >= hideStart && begin < hideEnd)
+ {
+ *begin = static_cast<uint32_t>(mSubstituteText);
+ sourcePos++;
+ }
+ else
+ {
+ *begin = *sourcePos++;
+ }
}
}
mPreviousTextCount = characterCount;
}
+void HiddenText::InitPreviousTextCount()
+{
+ mPreviousTextCount = 0u;
+}
+
bool HiddenText::OnTick()
{
if(mObserver != NULL)
{
mObserver->DisplayTimeExpired();
}
-
+ mIsLastCharacterShow = false;
return false;
}
* @param[in] source The original text
* @param[out] destination The applied text
*/
- void Substitute(const Vector<Character>& source, Vector<Character>& destination);
+ void Substitute(const Vector<Character>& source, Vector<Character>& destination, Length currentCursorIndex);
+
+ /**
+ * @brief Initialize the value of PreviousTextCount
+ */
+ void InitPreviousTextCount();
/**
* @brief Invoked when the timer is expired
int mDisplayDuration;
int mSubstituteCount;
Length mPreviousTextCount;
+ bool mIsLastCharacterShow;
};
} // namespace Text