mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 02:27:43 +00:00
KeyboardMapper: Fix displaying null characters
Fixes a bug where KeyButtons would display null characters. A single null character should be handled as an empty string.
This commit is contained in:
parent
41b0795f99
commit
35afd32a51
1 changed files with 8 additions and 7 deletions
|
@ -40,14 +40,15 @@ void KeyButton::paint_event(GUI::PaintEvent& event)
|
||||||
painter.draw_rect(key_cap_face_border_rect, Color::from_rgb(0x8C7272), false);
|
painter.draw_rect(key_cap_face_border_rect, Color::from_rgb(0x8C7272), false);
|
||||||
painter.fill_rect(key_cap_face_rect, face_color);
|
painter.fill_rect(key_cap_face_rect, face_color);
|
||||||
|
|
||||||
if (!text().is_empty()) {
|
if (text().is_empty() || text().starts_with('\0'))
|
||||||
Gfx::IntRect text_rect { 0, 0, font.width(text()), font.glyph_height() };
|
return;
|
||||||
text_rect.align_within(key_cap_face_rect, Gfx::TextAlignment::Center);
|
|
||||||
|
|
||||||
painter.draw_text(text_rect, text(), font, Gfx::TextAlignment::Center, Color::Black, Gfx::TextElision::Right);
|
Gfx::IntRect text_rect { 0, 0, font.width(text()), font.glyph_height() };
|
||||||
if (is_focused())
|
text_rect.align_within(key_cap_face_rect, Gfx::TextAlignment::Center);
|
||||||
painter.draw_rect(text_rect.inflated(6, 4), palette().focus_outline());
|
|
||||||
}
|
painter.draw_text(text_rect, text(), font, Gfx::TextAlignment::Center, Color::Black, Gfx::TextElision::Right);
|
||||||
|
if (is_focused())
|
||||||
|
painter.draw_rect(text_rect.inflated(6, 4), palette().focus_outline());
|
||||||
}
|
}
|
||||||
|
|
||||||
void KeyButton::click(unsigned)
|
void KeyButton::click(unsigned)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue