Lines 136-141
Link Here
|
136 |
filter = new Listener() { |
136 |
filter = new Listener() { |
137 |
public void handleEvent(Event event) { |
137 |
public void handleEvent(Event event) { |
138 |
if (isDisposed ()) return; |
138 |
if (isDisposed ()) return; |
|
|
139 |
if (event.type == SWT.Selection) { |
140 |
if (event.widget instanceof ScrollBar) { |
141 |
handleScroll(event); |
142 |
} |
143 |
return; |
144 |
} |
139 |
Shell shell = ((Control)event.widget).getShell (); |
145 |
Shell shell = ((Control)event.widget).getShell (); |
140 |
if (shell == CCombo.this.getShell ()) { |
146 |
if (shell == CCombo.this.getShell ()) { |
141 |
handleFocus (SWT.FocusOut); |
147 |
handleFocus (SWT.FocusOut); |
Lines 532-538
Link Here
|
532 |
} |
538 |
} |
533 |
void dropDown (boolean drop) { |
539 |
void dropDown (boolean drop) { |
534 |
if (drop == isDropped ()) return; |
540 |
if (drop == isDropped ()) return; |
|
|
541 |
Display display = getDisplay (); |
535 |
if (!drop) { |
542 |
if (!drop) { |
|
|
543 |
display.removeFilter (SWT.Selection, filter); |
536 |
popup.setVisible (false); |
544 |
popup.setVisible (false); |
537 |
if (!isDisposed () && isFocusControl()) { |
545 |
if (!isDisposed () && isFocusControl()) { |
538 |
text.setFocus(); |
546 |
text.setFocus(); |
Lines 559-565
Link Here
|
559 |
|
567 |
|
560 |
int index = list.getSelectionIndex (); |
568 |
int index = list.getSelectionIndex (); |
561 |
if (index != -1) list.setTopIndex (index); |
569 |
if (index != -1) list.setTopIndex (index); |
562 |
Display display = getDisplay (); |
|
|
563 |
Rectangle listRect = list.getBounds (); |
570 |
Rectangle listRect = list.getBounds (); |
564 |
Rectangle parentRect = display.map (getParent (), null, getBounds ()); |
571 |
Rectangle parentRect = display.map (getParent (), null, getBounds ()); |
565 |
Point comboSize = getSize (); |
572 |
Point comboSize = getSize (); |
Lines 573-578
Link Here
|
573 |
popup.setBounds (x, y, width, height); |
580 |
popup.setBounds (x, y, width, height); |
574 |
popup.setVisible (true); |
581 |
popup.setVisible (true); |
575 |
if (isFocusControl()) list.setFocus (); |
582 |
if (isFocusControl()) list.setFocus (); |
|
|
583 |
|
584 |
/* |
585 |
* Add a filter to listen to scrolling of the parent composite, when the |
586 |
* drop-down is visible. Remove the filter when drop-down is not |
587 |
* visible. |
588 |
*/ |
589 |
display.removeFilter (SWT.Selection, filter); |
590 |
display.addFilter (SWT.Selection, filter); |
576 |
} |
591 |
} |
577 |
/* |
592 |
/* |
578 |
* Return the lowercase of the first non-'&' character following |
593 |
* Return the lowercase of the first non-'&' character following |
Lines 865-870
Link Here
|
865 |
} |
880 |
} |
866 |
} |
881 |
} |
867 |
} |
882 |
} |
|
|
883 |
void handleScroll(Event event) { |
884 |
ScrollBar scrollBar = (ScrollBar)event.widget; |
885 |
Control scrollableParent = scrollBar.getParent(); |
886 |
if (scrollableParent.equals(list)) return; |
887 |
if (isParentScrolling(scrollableParent)) dropDown(false); |
888 |
} |
868 |
/** |
889 |
/** |
869 |
* Searches the receiver's list starting at the first item |
890 |
* Searches the receiver's list starting at the first item |
870 |
* (index 0) until an item is found that is equal to the |
891 |
* (index 0) until an item is found that is equal to the |
Lines 1023-1028
Link Here
|
1023 |
} |
1044 |
} |
1024 |
return super.isFocusControl (); |
1045 |
return super.isFocusControl (); |
1025 |
} |
1046 |
} |
|
|
1047 |
boolean isParentScrolling(Control scrollableParent) { |
1048 |
Control parent = this.getParent(); |
1049 |
while (parent != null) { |
1050 |
if (parent.equals(scrollableParent)) |
1051 |
return true; |
1052 |
parent = parent.getParent(); |
1053 |
} |
1054 |
return false; |
1055 |
} |
1026 |
void internalLayout (boolean changed) { |
1056 |
void internalLayout (boolean changed) { |
1027 |
if (isDropped ()) dropDown (false); |
1057 |
if (isDropped ()) dropDown (false); |
1028 |
Rectangle rect = getClientArea (); |
1058 |
Rectangle rect = getClientArea (); |