Skip to content

Commit 93237ac

Browse files
author
zhourenjian
committed
Fixed bug that Arrow key <Up> and <Down> in Combo do not get response correctly
1 parent 0840673 commit 93237ac

File tree

1 file changed

+20
-7
lines changed
  • sources/net.sf.j2s.java.org.eclipse.swt/src/org/eclipse/swt/widgets

1 file changed

+20
-7
lines changed

sources/net.sf.j2s.java.org.eclipse.swt/src/org/eclipse/swt/widgets/Combo.java

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -609,31 +609,44 @@ public void run(){
609609
if (items.length == 0) {
610610
return;
611611
}
612+
if (e.keyCode == 38 || e.keyCode == 40) {
613+
String text = getText();
614+
currentIndex = -1;
615+
for (int i = 0; i < items.length; i++) {
616+
if (text.equals(items[i])) {
617+
currentIndex = i;
618+
break;
619+
}
620+
}
621+
if (currentIndex < 0) {
622+
currentIndex = selectInput.selectedIndex;
623+
}
624+
}
612625
switch(e.keyCode){
613626
case 38:
614-
selectInput.selectedIndex = currentIndex;
615-
noSelection = false;
616-
updateSelection();
617-
noSelection = true;
618627
if (currentIndex > 0) {
619628
currentIndex--;
620629
}
621630
if (currentIndex >= items.length) {
622631
currentIndex = items.length - 1;
623632
}
624-
toReturn(false);
625-
break;
626-
case 40:
627633
selectInput.selectedIndex = currentIndex;
628634
noSelection = false;
629635
updateSelection();
630636
noSelection = true;
637+
toReturn(false);
638+
break;
639+
case 40:
631640
if (currentIndex < items.length) {
632641
currentIndex++;
633642
}
634643
if (currentIndex >= items.length) {
635644
currentIndex = items.length - 1;
636645
}
646+
selectInput.selectedIndex = currentIndex;
647+
noSelection = false;
648+
updateSelection();
649+
noSelection = true;
637650
toReturn(false);
638651
break;
639652
}

0 commit comments

Comments
 (0)