2424import org .eclipse .swt .internal .xhtml .HTMLEvent ;
2525import org .eclipse .swt .internal .xhtml .Option ;
2626import org .eclipse .swt .internal .xhtml .document ;
27+ import org .eclipse .swt .internal .xhtml .window ;
2728
2829/**
2930 * Instances of this class are controls that allow the user
@@ -551,33 +552,10 @@ protected void createHandle () {
551552 textInput .type = "text" ;
552553 textInput .className = "combo-input-box" ;
553554 textInput .readOnly = (style & SWT .READ_ONLY )!=0 ;
554- textInput .size = Combo .LIMIT ;
555+ // textInput.size = Combo.LIMIT;
555556 handle .appendChild (textInput );
556557
557- int height = OS .getContainerHeight (dropDownButton );
558-
559- selectInput = document .createElement ("SELECT" );
560- if (isSimple ){
561- selectInput .style .top = height + "px" ;
562- selectInput .style .left = textInput .style .left ;
563- // System.out.println("is Simple " + isSimple);
564- selectInput .className = "combo-select-box-visible" ;
565- selectInput .size = visibleCount ;
566- handle .appendChild (selectInput );
567- }else {
568- selectInput .style .top = height + "px" ;
569- selectInput .style .left = textInput .style .left ;
570- // System.out.println("is Simple " + isSimple);
571- selectInput .className = "combo-select-box-invisible combo-select-box-notsimple" ;
572- selectInput .size = visibleCount ;
573- // System.out.println("ho combo1 " + textInput.scrollHeight);
574- // System.out.println("ho combo2 " + textInput.offsetHeight);
575- // System.out.println("ho combo3 " + textInput.clientHeight);
576- //TODO: add the select to shell to be shown every where
577-
578- getShell ().handle .appendChild (selectInput );
579- // handle.appendChild(selectInput);
580- }
558+ //int height = OS.getContainerHeight(dropDownButton);
581559
582560 textInput .ondblclick = new RunnableCompatibility () {
583561 public void run () {
@@ -624,6 +602,28 @@ public void run() {
624602 }
625603 };
626604
605+ createSelect ();
606+ configureSelect ();
607+ }
608+
609+ void createSelect () {
610+ selectInput = document .createElement ("SELECT" );
611+ if (isSimple ){
612+ selectInput .style .top = height + "px" ;
613+ selectInput .style .left = textInput .style .left ;
614+ selectInput .className = "combo-select-box-visible" ;
615+ selectInput .size = visibleCount ;
616+ handle .appendChild (selectInput );
617+ }else {
618+ selectInput .style .position = "absolute" ;
619+ selectInput .style .top = height + "px" ;
620+ selectInput .style .left = textInput .style .left ;
621+ selectInput .className = "combo-select-box-invisible combo-select-box-notsimple" ;
622+ selectInput .size = visibleCount ;
623+ handle .appendChild (selectInput );
624+ }
625+ }
626+ void configureSelect () {
627627 selectInput .onchange = new RunnableCompatibility () {
628628 public void run () {
629629// System.out.println("select changed!" + selectInput.selectedIndex);
@@ -634,7 +634,7 @@ public void run() {
634634 }
635635 };
636636
637- selectInput .onselectchange = selectInput . onblur = new RunnableCompatibility () {
637+ selectInput .onblur = new RunnableCompatibility () {
638638 public void run () {
639639// System.out.println("handle blurred!");
640640// updateSelection();
@@ -649,16 +649,18 @@ public void run() {
649649// hide();
650650// }
651651// };
652-
653-
654652}
655-
656653void hide (){
657- // if(!this.selectShown){
658- // return;
659- // }
660-
654+ if (!this .selectShown ){
655+ return ;
656+ }
661657 this .selectShown = false ;
658+ try {
659+ document .body .removeChild (selectInput );
660+ handle .appendChild (selectInput );
661+ } catch (Throwable e ) {
662+
663+ }
662664 selectInput .className = "combo-select-box-invisible" + (isSimple ? "" : " combo-select-box-notsimple" );
663665}
664666
@@ -668,13 +670,26 @@ void show(){
668670// return;
669671// }
670672
671- Point coordinate = OS .calcuateRelativePosition (textInput , getShell ().handle );
673+ Point coordinate = OS .calcuateRelativePosition (handle , document .body );
674+ coordinate .y += OS .getContainerHeight (handle );
675+ if (OS .isFirefox ) {
676+ coordinate .x += 1 ;
677+ coordinate .y += 1 ;
678+ } else if (OS .isIE ) {
679+ coordinate .x -= 1 ;
680+ coordinate .y -= 2 ;
681+ }
672682 this .selectShown = true ;
673- selectInput .style .zIndex = "120" ;
683+ window .currentTopZIndex = "" + (Integer .parseInt (window .currentTopZIndex ) + 1 );
684+ selectInput .style .zIndex = window .currentTopZIndex ;
685+ try {
686+ handle .removeChild (selectInput );
687+ document .body .appendChild (selectInput );
688+ } catch (Throwable e ) {
689+ }
674690 selectInput .className = "combo-select-box-visible" + (isSimple ? "" : " combo-select-box-notsimple" );
675- selectInput .style .top = (coordinate .y + 2 ) + "px" ;
676- selectInput .style .left = (coordinate .x - 4 ) + "px" ;
677- // System.out.println("Z " + selectInput.style.zIndex);
691+ selectInput .style .top = coordinate .y + "px" ;
692+ selectInput .style .left = coordinate .x + "px" ;
678693 try {
679694 selectInput .focus ();
680695 } catch (Throwable e ) {
@@ -2501,7 +2516,7 @@ void enableWidget(boolean enabled) {
25012516}
25022517protected boolean SetWindowPos (Object hWnd , Object hWndInsertAfter , int X , int Y , int cx , int cy , int uFlags ) {
25032518 if (OS .isIE ) {
2504- dropDownButton .style .height = (cy - 2 ) + "px" ;
2519+ dropDownButton .style .height = (cy - 4 ) + "px" ;
25052520 }
25062521 OS .updateArrowSize (dropDownButton .childNodes [0 ], SWT .DOWN , 16 , cy );
25072522
0 commit comments