diff options
author | Kae <80987908+Novaenia@users.noreply.github.com> | 2023-06-28 01:40:55 +1000 |
---|---|---|
committer | Kae <80987908+Novaenia@users.noreply.github.com> | 2023-06-28 01:40:55 +1000 |
commit | cd497bbcf399bcfa17694725583cefd93bff65d9 (patch) | |
tree | c91cf4e089bb1c2c46bf8f3f44cf8d49cb4684d7 /source/windowing/StarTextBoxWidget.cpp | |
parent | 4c006afc94e4994f215eddaa35ee22358d963019 (diff) |
Support for hiding text box input, hide server connection password box by default
Diffstat (limited to 'source/windowing/StarTextBoxWidget.cpp')
-rw-r--r-- | source/windowing/StarTextBoxWidget.cpp | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/source/windowing/StarTextBoxWidget.cpp b/source/windowing/StarTextBoxWidget.cpp index 7c69fb1..0622d89 100644 --- a/source/windowing/StarTextBoxWidget.cpp +++ b/source/windowing/StarTextBoxWidget.cpp @@ -8,6 +8,7 @@ namespace Star { TextBoxWidget::TextBoxWidget(String const& startingText, String const& hint, WidgetCallbackFunc callback) : m_text(startingText), m_hint(hint), m_callback(callback) { auto assets = Root::singleton().assets(); + m_textHidden = false; m_regex = ".*"; m_repeatKeyThreshold = 0; m_repeatCode = SpecialRepeatKeyCodes::None; @@ -61,7 +62,12 @@ void TextBoxWidget::renderImpl() { context()->renderInterfaceText(m_hint, {pos, m_hAnchor, m_vAnchor}); } else { context()->setFontColor(m_color.mix(Color::rgbf(0, 0, 1), blueRate).toRgba()); - context()->renderInterfaceText(m_text, {pos, m_hAnchor, m_vAnchor}); + if (m_textHidden) { + String hiddenText('*', m_text.length()); + context()->renderInterfaceText(hiddenText, { pos, m_hAnchor, m_vAnchor }); + } + else + context()->renderInterfaceText(m_text, { pos, m_hAnchor, m_vAnchor }); } context()->setDefaultFont(); context()->setFontProcessingDirectives(""); @@ -136,7 +142,7 @@ void TextBoxWidget::update() { } } -String TextBoxWidget::getText() { +String TextBoxWidget::getText() const { return m_text; } @@ -155,6 +161,14 @@ bool TextBoxWidget::setText(String const& text, bool callback) { return true; } +bool TextBoxWidget::getHidden() const { + return m_textHidden; +} + +void TextBoxWidget::setHidden(bool hidden) { + m_textHidden = hidden; +} + String TextBoxWidget::getRegex() { return m_regex; } |