8000 servoshell: Select address bar text on click (#37839) · servo/servo@e3baec4 · GitHub
[go: up one dir, main page]

Skip to content

Commit e3baec4

Browse files
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>
1 parent ca47cc2 commit e3baec4

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

ports/servoshell/desktop/minibrowser.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,11 @@ impl Minibrowser {
340340
i.clone().consume_key(Modifiers::ALT, Key::D)
341341
}
342342
}) {
343+
// The focus request immediately makes gained_focus return true.
343344
location_field.request_focus();
345+
}
346+
// Select address bar text when it's focused (click or shortcut).
347+
if location_field.gained_focus() {
344348
if let Some(mut state) =
345349
TextEditState::load(ui.ctx(), location_id)
346350
{
@@ -352,6 +356,7 @@ impl Minibrowser {
352356
state.store(ui.ctx(), location_id);
353357
}
354358
}
359+
// Navigate to address when enter is pressed in the address bar.
355360
if location_field.lost_focus() &&
356361
ui.input(|i| i.clone().key_pressed(Key::Enter))
357362
{

0 commit comments

Comments
 (0)
0