From bdaa3fc11ce6b836959fd7817fe04128d38b601b Mon Sep 17 00:00:00 2001 From: Phil Crosby Date: Sun, 6 Dec 2009 00:54:53 -0800 Subject: Put the cursor at the end of the text field when selecting it via link hints. Fixes #19. --- linkHints.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/linkHints.js b/linkHints.js index fdafa1ed..d3f6f14b 100644 --- a/linkHints.js +++ b/linkHints.js @@ -154,11 +154,15 @@ function updateLinkHints() { deactivateLinkHintsMode(); else if (linksMatched.length == 1) { var matchedLink = linksMatched[0]; - // Don't navigate to the selected link immediately; we want to give the user some feedback depicting - // which link they've selected by focusing it. Note that for textareas and inputs, the click - // event is ignored, but focus causes the desired behavior. - setTimeout(function() { simulateClick(matchedLink); }, 600); - matchedLink.focus(); + if (isInputOrText(matchedLink)) { + matchedLink.focus(); + matchedLink.setSelectionRange(matchedLink.value.length, matchedLink.value.length); + } else { + // Don't navigate to the selected link immediately; we want to give the user some feedback depicting + // which link they've selected by focusing it. + setTimeout(function() { simulateClick(matchedLink); }, 400); + matchedLink.focus(); + } deactivateLinkHintsMode(); } } -- cgit v1.2.3