From 254f2d01379a253409fbd0178b1b7816c35ef1c3 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Fri, 28 Apr 2017 21:33:10 +0200 Subject: [PATCH] [DEV] add suport oh hidding pasword in entry --- ewol/widget/Entry.cpp | 19 +++++++++++++++++-- ewol/widget/Entry.hpp | 2 ++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/ewol/widget/Entry.cpp b/ewol/widget/Entry.cpp index e7f5beb8..66575d0a 100644 --- a/ewol/widget/Entry.cpp +++ b/ewol/widget/Entry.cpp @@ -20,6 +20,10 @@ ewol::widget::Entry::Entry() : signalClick(this, "click", "the user Click on the Entry box"), signalEnter(this, "enter", "The cursor enter inside the button"), signalModify(this, "modify", "Entry box value change"), + propertyPassword(this, "password", + false, + "Not display content in password mode", + &ewol::widget::Entry::onChangePropertyPassword), propertyShape(this, "shape", "{ewol}THEME:GUI:Entry.json", "Shaper to display the background", @@ -157,8 +161,15 @@ void ewol::widget::Entry::onRegenerateDisplay() { } else { m_text.setCursorPos(m_displayCursorPos); } - if (propertyValue->size() != 0) { - m_text.print(propertyValue); + std::string valueToDisplay = *propertyValue; + if (*propertyPassword == true) { + for (auto &it: valueToDisplay) { + it = '*'; + } + } + + if (valueToDisplay.size() != 0) { + m_text.print(valueToDisplay); } else { if (propertyTextWhenNothing->size() != 0) { m_text.printDecorated(propertyTextWhenNothing); @@ -552,6 +563,10 @@ void ewol::widget::Entry::periodicCall(const ewol::event::Time& _event) { markToRedraw(); } +void ewol::widget::Entry::onChangePropertyPassword() { + markToRedraw(); +} + void ewol::widget::Entry::onChangePropertyShaper() { m_shaper.setSource(propertyShape.get()); m_colorIdTextFg = m_shaper.requestColor("text-foreground"); diff --git a/ewol/widget/Entry.hpp b/ewol/widget/Entry.hpp index 97cf84a0..7ea88c93 100644 --- a/ewol/widget/Entry.hpp +++ b/ewol/widget/Entry.hpp @@ -37,6 +37,7 @@ namespace ewol { esignal::Signal signalEnter; //!< Enter key is pressed esignal::Signal signalModify; //!< data change public: // propertie list + eproperty::Value propertyPassword; //!< Disable display of the content of the entry eproperty::Value propertyShape; eproperty::Value propertyValue; //!< string that must be displayed eproperty::Range propertyMaxCharacter; //!< number max of xharacter in the list @@ -129,6 +130,7 @@ namespace ewol { void onCallbackPaste(); void onCallbackSelect(bool _all); protected: + virtual void onChangePropertyPassword(); virtual void onChangePropertyShaper(); virtual void onChangePropertyValue(); virtual void onChangePropertyMaxCharacter();