git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [EGIT PATCH] Use keyboard arrow keys to go to the next and previous find results.
@ 2008-02-01  2:12 Roger C. Soares
  2008-02-01  5:48 ` Robin Rosenberg
  0 siblings, 1 reply; 2+ messages in thread
From: Roger C. Soares @ 2008-02-01  2:12 UTC (permalink / raw)
  To: git; +Cc: robin.rosenberg, Roger C. Soares

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

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-02-01  5:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-01  2:12 [EGIT PATCH] Use keyboard arrow keys to go to the next and previous find results Roger C. Soares
2008-02-01  5:48 ` Robin Rosenberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).