1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 13:57:35 +00:00

LibGUI+Browser: Add UrlBox class

This allows the address bar to "select all" when initially gaining focus
as Firefox and Chrome do. A future improvement on this would be for the
Widget class to mange and provide focus transition as part of the events
instead of the UrlBox class. Currently focus is updated before the event
is provided to the UrlBox class.
This commit is contained in:
Rob Ryan 2021-08-15 15:48:53 +10:00 committed by Andreas Kling
parent fbf824a50f
commit 34a64ed25b
7 changed files with 68 additions and 8 deletions

View file

@ -256,10 +256,7 @@ void TextEditor::mousedown_event(MouseEvent& event)
if (m_triple_click_timer.is_valid() && m_triple_click_timer.elapsed() < 250) {
m_triple_click_timer = Core::ElapsedTimer();
m_selection = document().range_for_entire_line(m_cursor.line());
set_cursor(m_selection.end());
update();
did_update_selection();
select_current_line();
return;
}
@ -310,6 +307,14 @@ void TextEditor::mousemove_event(MouseEvent& event)
}
}
void TextEditor::select_current_line()
{
m_selection = document().range_for_entire_line(m_cursor.line());
set_cursor(m_selection.end());
update();
did_update_selection();
}
void TextEditor::automatic_selection_scroll_timer_fired()
{
if (!m_in_drag_select) {