LibGUI: When focusing a TextEditor via keyboard, select all contents

This feels very natural and allows you to start typing immediately
knowing it will replace whatever was in the text box before.
This commit is contained in:
Andreas Kling 2020-08-14 19:58:38 +02:00
parent 75b8f4e4e6
commit c1e0047b48
Notes: sideshowbarker 2024-07-19 03:38:07 +09:00

View file

@ -1147,8 +1147,10 @@ void TextEditor::set_cursor(const TextPosition& a_position)
m_highlighter->cursor_did_change();
}
void TextEditor::focusin_event(FocusEvent&)
void TextEditor::focusin_event(FocusEvent& event)
{
if (event.source() == FocusSource::Keyboard)
select_all();
m_cursor_state = true;
update_cursor();
start_timer(500);