Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ctrl-L doesn't select the content of the address bar #159

Closed
hrj opened this issue Sep 14, 2015 · 3 comments · Fixed by #163
Closed

Ctrl-L doesn't select the content of the address bar #159

hrj opened this issue Sep 14, 2015 · 3 comments · Fixed by #163

Comments

@hrj
Copy link
Member

hrj commented Sep 14, 2015

The keyboard shortcut Ctrl-L properly puts the focus into the address bar. It however doesn't select the text automatically.

Selecting automatically will allow the user to type a new URL immediately.

@bogas04
Copy link
Contributor

bogas04 commented Sep 14, 2015

I'm willing to take this up! Can you tell me which part of code deals with shortcut event listeners ?

@hrj
Copy link
Member Author

hrj commented Sep 14, 2015

@bogas04 Cool!

There is a class called AddressField and an instance of this is managed by ComponentSource.

I am about to travel, so can't find the exact place where the short cut is used right now. I will be back after a couple of hours. If you can't find the relevant part in the meanwhile, let me know.

@hrj
Copy link
Member Author

hrj commented Sep 14, 2015

Found it! In AddressField class, there is this code:

    getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ctrl L"), "edit URL");
    getActionMap().put("edit URL", new AbstractAction() {

      public void actionPerformed(final ActionEvent e) {
        requestFocus();
      }
    });

It is currently only requesting focus. You need to also make it select the text.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants