mirror of
https://github.com/servo/servo.git
synced 2025-07-15 03:13:41 +01:00
servoshell: Select address bar text on click (#37839)
In Firefox, clicking on the address bar selects all the text. This makes Servo to do the same. I reworked the code so that the shortcut only changes the focus. That means that either clicking or the shortcut changes the focus which in turn selects the text. Testing: I tested it manually by clicking in the address bar and using the shortcuts and noticing that the text was selected. Signed-off-by: Michael Mc Donnell <michael@mcdonnell.dk>
This commit is contained in:
parent
ca47cc2fa3
commit
e3baec4807
1 changed files with 5 additions and 0 deletions
|
@ -340,7 +340,11 @@ impl Minibrowser {
|
|||
i.clone().consume_key(Modifiers::ALT, Key::D)
|
||||
}
|
||||
}) {
|
||||
// The focus request immediately makes gained_focus return true.
|
||||
location_field.request_focus();
|
||||
}
|
||||
// Select address bar text when it's focused (click or shortcut).
|
||||
if location_field.gained_focus() {
|
||||
if let Some(mut state) =
|
||||
TextEditState::load(ui.ctx(), location_id)
|
||||
{
|
||||
|
@ -352,6 +356,7 @@ impl Minibrowser {
|
|||
state.store(ui.ctx(), location_id);
|
||||
}
|
||||
}
|
||||
// Navigate to address when enter is pressed in the address bar.
|
||||
if location_field.lost_focus() &&
|
||||
ui.input(|i| i.clone().key_pressed(Key::Enter))
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue