mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 18:47:34 +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:
parent
fbf824a50f
commit
34a64ed25b
7 changed files with 68 additions and 8 deletions
|
@ -8,6 +8,7 @@
|
|||
|
||||
REGISTER_WIDGET(GUI, TextBox)
|
||||
REGISTER_WIDGET(GUI, PasswordBox)
|
||||
REGISTER_WIDGET(GUI, UrlBox)
|
||||
|
||||
namespace GUI {
|
||||
|
||||
|
@ -80,4 +81,38 @@ PasswordBox::PasswordBox()
|
|||
set_text_is_secret(true);
|
||||
}
|
||||
|
||||
UrlBox::UrlBox()
|
||||
: TextBox()
|
||||
{
|
||||
set_auto_focusable(false);
|
||||
}
|
||||
|
||||
UrlBox::~UrlBox()
|
||||
{
|
||||
}
|
||||
|
||||
void UrlBox::focusout_event(GUI::FocusEvent& event)
|
||||
{
|
||||
set_focus_transition(true);
|
||||
|
||||
TextBox::focusout_event(event);
|
||||
}
|
||||
|
||||
void UrlBox::mousedown_event(GUI::MouseEvent& event)
|
||||
{
|
||||
if (is_displayonly())
|
||||
return;
|
||||
|
||||
if (event.button() != MouseButton::Left)
|
||||
return;
|
||||
|
||||
if (is_focus_transition()) {
|
||||
TextBox::select_current_line();
|
||||
|
||||
set_focus_transition(false);
|
||||
} else {
|
||||
TextBox::mousedown_event(event);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue