Skip to content

Commit 8714976

Browse files
author
jossonsmith
committed
Fixed bug that Combo's SWT.DROP_DOWN is not correctly responsing when item is selected
Showing Combo's caret.
1 parent 091dcaa commit 8714976

File tree

1 file changed

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

1 file changed

+22
-10
lines changed

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

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import org.eclipse.swt.internal.RunnableCompatibility;
2525
import org.eclipse.swt.internal.browser.OS;
2626
import org.eclipse.swt.internal.browser.Popup;
27+
import org.eclipse.swt.internal.dnd.HTMLEventWrapper;
2728
import org.eclipse.swt.internal.xhtml.Element;
2829
import org.eclipse.swt.internal.xhtml.HTMLEvent;
2930
import org.eclipse.swt.internal.xhtml.Option;
@@ -567,7 +568,11 @@ protected void createHandle () {
567568
textInput.className = "combo-input-box";
568569
textInput.readOnly = (style & SWT.READ_ONLY)!=0;
569570
//textInput.size = Combo.LIMIT;
570-
handle.appendChild(textInput);
571+
Element wrapper = document.createElement("DIV");
572+
wrapper.style.overflow = "auto";
573+
handle.appendChild(wrapper);
574+
wrapper.appendChild(textInput);
575+
//handle.appendChild(textInput);
571576

572577
//int height = OS.getContainerHeight(dropDownButton);
573578

@@ -653,13 +658,18 @@ public void run() {
653658
hide();
654659
}
655660
};
656-
// selectInput.onmousedown = new RunnableCompatibility() {
657-
// public void run() {
658-
// System.out.println("select mouse down!");
659-
// updateSelection();
660-
// hide();
661-
// }
662-
// };
661+
selectInput.onmouseup = new RunnableCompatibility() {
662+
public void run() {
663+
noSelection = false;
664+
updateSelection();
665+
if(!isSimple && itemCount > 0) {
666+
Element el = new HTMLEventWrapper(getEvent()).target;
667+
if (el != null && el.nodeName == "OPTION") {
668+
hide();
669+
}
670+
}
671+
}
672+
};
663673
}
664674
void hide(){
665675
if(!this.selectShown){
@@ -734,8 +744,10 @@ void show(){
734744
}
735745

736746
void updateSelection(){
737-
textInput.value = selectInput.options[getSelectionIndex()].value;
738-
setText(getItem(getSelectionIndex()));
747+
int i = getSelectionIndex();
748+
if (i < 0) return;
749+
textInput.value = selectInput.options[i].value;
750+
setText(getItem(i));
739751
sendEvent(SWT.Selection);
740752
}
741753

0 commit comments

Comments
 (0)