فهرست منبع

LibGUI: Don't render placeholders as secret

before my placeholder 'password' showed up as '********'.
Peter Elliott 3 سال پیش
والد
کامیت
c19d868a3e
1فایلهای تغییر یافته به همراه3 افزوده شده و 3 حذف شده
  1. 3 3
      Userland/Libraries/LibGUI/TextEditor.cpp

+ 3 - 3
Userland/Libraries/LibGUI/TextEditor.cpp

@@ -402,8 +402,8 @@ void TextEditor::paint_event(PaintEvent& event)
 
     // NOTE: This lambda and TextEditor::text_width_for_font() are used to substitute all glyphs with m_substitution_code_point if necessary.
     //       Painter::draw_text() and Gfx::Font::width() should not be called directly, but using this lambda and TextEditor::text_width_for_font().
-    auto draw_text = [&](Gfx::IntRect const& rect, auto const& raw_text, Gfx::Font const& font, Gfx::TextAlignment alignment, Gfx::Color color) {
-        if (m_substitution_code_point) {
+    auto draw_text = [&](Gfx::IntRect const& rect, auto const& raw_text, Gfx::Font const& font, Gfx::TextAlignment alignment, Gfx::Color color, bool substitue = true) {
+        if (m_substitution_code_point && substitue) {
             painter.draw_text(rect, substitution_code_point_view(raw_text.length()), font, alignment, color);
         } else {
             painter.draw_text(rect, raw_text, font, alignment, color);
@@ -519,7 +519,7 @@ void TextEditor::paint_event(PaintEvent& event)
             if (!placeholder().is_empty() && document().is_empty() && line_index == 0) {
                 auto line_rect = visual_line_rect;
                 line_rect.set_width(text_width_for_font(placeholder(), font()));
-                draw_text(line_rect, placeholder(), font(), m_text_alignment, palette().color(Gfx::ColorRole::PlaceholderText));
+                draw_text(line_rect, placeholder(), font(), m_text_alignment, palette().color(Gfx::ColorRole::PlaceholderText), false);
             } else if (!document().has_spans()) {
                 // Fast-path for plain text
                 auto color = palette().color(is_enabled() ? foreground_role() : Gfx::ColorRole::DisabledText);