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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxxx>
---
 .../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

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux