[DEV] add suport oh hidding pasword in entry

This commit is contained in:
Edouard DUPIN 2017-04-28 21:33:10 +02:00
parent 225633ffeb
commit 254f2d0137
2 changed files with 19 additions and 2 deletions

View File

@ -20,6 +20,10 @@ ewol::widget::Entry::Entry() :
signalClick(this, "click", "the user Click on the Entry box"), signalClick(this, "click", "the user Click on the Entry box"),
signalEnter(this, "enter", "The cursor enter inside the button"), signalEnter(this, "enter", "The cursor enter inside the button"),
signalModify(this, "modify", "Entry box value change"), signalModify(this, "modify", "Entry box value change"),
propertyPassword(this, "password",
false,
"Not display content in password mode",
&ewol::widget::Entry::onChangePropertyPassword),
propertyShape(this, "shape", propertyShape(this, "shape",
"{ewol}THEME:GUI:Entry.json", "{ewol}THEME:GUI:Entry.json",
"Shaper to display the background", "Shaper to display the background",
@ -157,8 +161,15 @@ void ewol::widget::Entry::onRegenerateDisplay() {
} else { } else {
m_text.setCursorPos(m_displayCursorPos); m_text.setCursorPos(m_displayCursorPos);
} }
if (propertyValue->size() != 0) { std::string valueToDisplay = *propertyValue;
m_text.print(propertyValue); if (*propertyPassword == true) {
for (auto &it: valueToDisplay) {
it = '*';
}
}
if (valueToDisplay.size() != 0) {
m_text.print(valueToDisplay);
} else { } else {
if (propertyTextWhenNothing->size() != 0) { if (propertyTextWhenNothing->size() != 0) {
m_text.printDecorated(propertyTextWhenNothing); m_text.printDecorated(propertyTextWhenNothing);
@ -552,6 +563,10 @@ void ewol::widget::Entry::periodicCall(const ewol::event::Time& _event) {
markToRedraw(); markToRedraw();
} }
void ewol::widget::Entry::onChangePropertyPassword() {
markToRedraw();
}
void ewol::widget::Entry::onChangePropertyShaper() { void ewol::widget::Entry::onChangePropertyShaper() {
m_shaper.setSource(propertyShape.get()); m_shaper.setSource(propertyShape.get());
m_colorIdTextFg = m_shaper.requestColor("text-foreground"); m_colorIdTextFg = m_shaper.requestColor("text-foreground");

View File

@ -37,6 +37,7 @@ namespace ewol {
esignal::Signal<std::string> signalEnter; //!< Enter key is pressed esignal::Signal<std::string> signalEnter; //!< Enter key is pressed
esignal::Signal<std::string> signalModify; //!< data change esignal::Signal<std::string> signalModify; //!< data change
public: // propertie list public: // propertie list
eproperty::Value<bool> propertyPassword; //!< Disable display of the content of the entry
eproperty::Value<std::string> propertyShape; eproperty::Value<std::string> propertyShape;
eproperty::Value<std::string> propertyValue; //!< string that must be displayed eproperty::Value<std::string> propertyValue; //!< string that must be displayed
eproperty::Range<int32_t> propertyMaxCharacter; //!< number max of xharacter in the list eproperty::Range<int32_t> propertyMaxCharacter; //!< number max of xharacter in the list
@ -129,6 +130,7 @@ namespace ewol {
void onCallbackPaste(); void onCallbackPaste();
void onCallbackSelect(bool _all); void onCallbackSelect(bool _all);
protected: protected:
virtual void onChangePropertyPassword();
virtual void onChangePropertyShaper(); virtual void onChangePropertyShaper();
virtual void onChangePropertyValue(); virtual void onChangePropertyValue();
virtual void onChangePropertyMaxCharacter(); virtual void onChangePropertyMaxCharacter();