You.i Engine
YiPasswordTextEditView.h
Go to the documentation of this file.
1 // © You i Labs Inc. 2000-2020. All rights reserved.
2 #ifndef _YI_PASSWORD_TEXT_EDIT_VIEW_H_
3 #define _YI_PASSWORD_TEXT_EDIT_VIEW_H_
4 
5 #include "utility/YiTimer.h"
6 #include "view/YiTextEditView.h"
7 
31 {
32 public:
34  virtual ~CYIPasswordTextEditView();
35 
41  char32_t GetMaskCharacter() const;
42 
48  uint64_t GetCharacterShowTime();
49 
55  void SetMaskCharacter(char32_t maskCharacter);
56 
64  void SetCharacterShowTime(uint64_t timeMs);
65 
73  void EnableMasking(bool maskChars);
74 
80  bool IsMaskingEnabled() const;
81 
82  // Overrides from CYITextEditView
83  virtual bool Init() override;
84  virtual void SetValue(CYIString text, bool notifyKeyboard = true) override;
85  virtual bool OnTextDeleted(int32_t beforeCursor, int32_t afterCursor) override;
86  virtual void OnTextReplaced(const CYIString &text, size_t cursor) override;
87  virtual void OnCursorPositionChanged(size_t cursor) override;
88 
89  virtual bool OnTextPasted(const CYIString &pText) override;
90  virtual bool HandleEvent(const std::shared_ptr<CYIEventDispatcher> &pDispatcher, CYIEvent *pEvent) override;
91 
92 protected:
96  virtual void UpdateTextView() override;
97 
103  void UpdateTextView(bool showLastChar);
104 
108  void HideLastCharacter();
109 
113  CYIString GetMaskedText(const CYIString &text, bool showLastChar) const;
114 
115 private:
116  bool m_maskingEnabled;
117  CYITimer m_lastCharacterShowTimer;
118  CYIString m_maskCharacter;
119 
121 };
122 
125 #endif // _YI_PASSWORD_TEXT_EDIT_VIEW_H_
void SetCharacterShowTime(uint64_t timeMs)
virtual bool OnTextDeleted(int32_t beforeCursor, int32_t afterCursor) override
Base class for events.
Definition: YiEvent.h:27
virtual void OnCursorPositionChanged(size_t cursor) override
Container class for Unicode strings. Conceptually, a CYIString object is a sequence of Unicode charac...
Definition: YiString.h:36
virtual void OnTextReplaced(const CYIString &text, size_t cursor) override
A CYITextEditView implementation which masks its contents.
Definition: YiPasswordTextEditView.h:30
virtual bool HandleEvent(const std::shared_ptr< CYIEventDispatcher > &pDispatcher, CYIEvent *pEvent) override
virtual void SetValue(CYIString text, bool notifyKeyboard=true) override
A low-precision timer driven by the update loop.
Definition: YiTimer.h:27
void SetMaskCharacter(char32_t maskCharacter)
virtual bool Init() override
uint64_t GetCharacterShowTime()
char32_t GetMaskCharacter() const
Displays text to the user and allows them to edit it.
Definition: YiTextEditView.h:52
void EnableMasking(bool maskChars)
#define YI_TYPE_BASES(CLASS, BASES...)
Definition: YiRtti.h:257
bool IsMaskingEnabled() const
virtual void UpdateTextView() override
CYIString GetMaskedText(const CYIString &text, bool showLastChar) const
virtual ~CYIPasswordTextEditView()
virtual bool OnTextPasted(const CYIString &pText) override