mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 08:47:34 +00:00
LibGUI: Draw the placeholder of a TextEditor also when it is focused
Previously focusing a TextEditor would cause the placeholder to disapper. This is unpractical editors that get focused automatically for example.
This commit is contained in:
parent
4f29d285dd
commit
f8798c154b
1 changed files with 2 additions and 1 deletions
|
@ -1,5 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
||||||
|
* Copyright (c) 2021, Jakob-Niklas See <git@nwex.de>
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
@ -510,7 +511,7 @@ void TextEditor::paint_event(PaintEvent& event)
|
||||||
if constexpr (TEXTEDITOR_DEBUG)
|
if constexpr (TEXTEDITOR_DEBUG)
|
||||||
painter.draw_rect(visual_line_rect, Color::Cyan);
|
painter.draw_rect(visual_line_rect, Color::Cyan);
|
||||||
|
|
||||||
if (!placeholder().is_empty() && document().is_empty() && !is_focused() && line_index == 0) {
|
if (!placeholder().is_empty() && document().is_empty() && line_index == 0) {
|
||||||
auto line_rect = visual_line_rect;
|
auto line_rect = visual_line_rect;
|
||||||
line_rect.set_width(text_width_for_font(placeholder(), font()));
|
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));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue