git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[EGIT PATCH] Use keyboard arrow keys to go to the next and previous find results.

From
RSRoger C. Soares <rogersoares@intelinet.com.br>
Date
Feb 1, 2008, 02:12 UTC
Message-ID
<1201831959-3805-1-git-send-email-rogersoares@intelinet.com.br>

On the history find toolbar, if the pattern text field has focus, the down arrow key will generate a next event and the up arrow key will generate the previous event.

Signed-off-by: Roger C. Soares <rogersoares@intelinet.com.br>
---
 .../src/org/spearce/egit/ui/FindToolbar.java       |   23 +++++++++++++++++++-
 1 files changed, 22 insertions(+), 1 deletions(-)
diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/FindToolbar.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/FindToolbar.java
index bc48371..5527453 100644
--- a/org.spearce.egit.ui/src/org/spearce/egit/ui/FindToolbar.java
+++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/FindToolbar.java
@@ -21,6 +21,8 @@ import java.util.List;
 
 import org.eclipse.core.runtime.Preferences;
 import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.KeyAdapter;
+import org.eclipse.swt.events.KeyEvent;
 import org.eclipse.swt.events.ModifyEvent;
 import org.eclipse.swt.events.ModifyListener;
 import org.eclipse.swt.events.SelectionAdapter;
@@ -193,7 +195,7 @@ public class FindToolbar extends Composite {
 			}
 		});
 
-		Listener findButtonsListener = new Listener() {
+		final Listener findButtonsListener = new Listener() {
 			public void handleEvent(Event event) {
 				if (patternField.getText().length() > 0
 						&& findResults.size() == 0) {
@@ -242,6 +244,25 @@ public class FindToolbar extends Composite {
 		nextButton.addListener(SWT.Selection, findButtonsListener);
 		previousButton.addListener(SWT.Selection, findButtonsListener);
 
+		patternField.addKeyListener(new KeyAdapter() {
+			private Event event = new Event();
+
+			@Override
+			public void keyPressed(KeyEvent e) {
+				if(e.keyCode == SWT.ARROW_DOWN) {
+					if(nextButton.isEnabled()) {
+						event.widget = nextButton;
+						findButtonsListener.handleEvent(event);
+					}
+				} else if(e.keyCode == SWT.ARROW_UP) {
+					if(previousButton.isEnabled()) {
+						event.widget = previousButton;
+						findButtonsListener.handleEvent(event);
+					}
+				}
+			}
+		});
+
 		caseItem.addSelectionListener(new SelectionAdapter() {
 			public void widgetSelected(SelectionEvent e) {
 				prefs.setValue(UIPreferences.FINDTOOLBAR_IGNORE_CASE, caseItem
-- 
1.5.3.7
Next: Robin Rosenberg
Message 1 of 2 in “Use keyboard arrow keys to go to the next and previous find results.”
  1. Use keyboard arrow keys to go to the next and previous find results.Roger C. Soares, Feb 1, 2008
  2. Robin RosenbergFeb 1, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.