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.widget instanceof ScrollBar && event.type == SWT.Selection) { |
140 |
handleScroll(event); |
141 |
return; |
142 |
} |
139 |
Shell shell = ((Control)event.widget).getShell (); |
143 |
Shell shell = ((Control)event.widget).getShell (); |
140 |
if (shell == CCombo.this.getShell ()) { |
144 |
if (shell == CCombo.this.getShell ()) { |
141 |
handleFocus (SWT.FocusOut); |
145 |
handleFocus (SWT.FocusOut); |
Lines 513-519
Link Here
|
513 |
} |
517 |
} |
514 |
void dropDown (boolean drop) { |
518 |
void dropDown (boolean drop) { |
515 |
if (drop == isDropped ()) return; |
519 |
if (drop == isDropped ()) return; |
|
|
520 |
Display display = getDisplay (); |
516 |
if (!drop) { |
521 |
if (!drop) { |
|
|
522 |
display.removeFilter (SWT.Selection, filter); |
517 |
popup.setVisible (false); |
523 |
popup.setVisible (false); |
518 |
if (!isDisposed () && isFocusControl()) { |
524 |
if (!isDisposed () && isFocusControl()) { |
519 |
text.setFocus(); |
525 |
text.setFocus(); |
Lines 540-546
Link Here
|
540 |
|
546 |
|
541 |
int index = list.getSelectionIndex (); |
547 |
int index = list.getSelectionIndex (); |
542 |
if (index != -1) list.setTopIndex (index); |
548 |
if (index != -1) list.setTopIndex (index); |
543 |
Display display = getDisplay (); |
|
|
544 |
Rectangle listRect = list.getBounds (); |
549 |
Rectangle listRect = list.getBounds (); |
545 |
Rectangle parentRect = display.map (getParent (), null, getBounds ()); |
550 |
Rectangle parentRect = display.map (getParent (), null, getBounds ()); |
546 |
Point comboSize = getSize (); |
551 |
Point comboSize = getSize (); |
Lines 554-559
Link Here
|
554 |
popup.setBounds (x, y, width, height); |
559 |
popup.setBounds (x, y, width, height); |
555 |
popup.setVisible (true); |
560 |
popup.setVisible (true); |
556 |
if (isFocusControl()) list.setFocus (); |
561 |
if (isFocusControl()) list.setFocus (); |
|
|
562 |
|
563 |
/* |
564 |
* Add a filter to listen to scrolling of the parent composite, when the |
565 |
* drop-down is visible. Remove the filter when drop-down is not |
566 |
* visible. |
567 |
*/ |
568 |
display.removeFilter (SWT.Selection, filter); |
569 |
display.addFilter (SWT.Selection, filter); |
557 |
} |
570 |
} |
558 |
/* |
571 |
/* |
559 |
* Return the lowercase of the first non-'&' character following |
572 |
* Return the lowercase of the first non-'&' character following |
Lines 846-851
Link Here
|
846 |
} |
859 |
} |
847 |
} |
860 |
} |
848 |
} |
861 |
} |
|
|
862 |
void handleScroll(Event event) { |
863 |
ScrollBar scrollBar = (ScrollBar)event.widget; |
864 |
Control scrollableParent = scrollBar.getParent(); |
865 |
if (scrollableParent.equals(list)) return; |
866 |
if (isParentScrolling(scrollableParent)) dropDown(false); |
867 |
} |
849 |
/** |
868 |
/** |
850 |
* Searches the receiver's list starting at the first item |
869 |
* Searches the receiver's list starting at the first item |
851 |
* (index 0) until an item is found that is equal to the |
870 |
* (index 0) until an item is found that is equal to the |
Lines 1004-1009
Link Here
|
1004 |
} |
1023 |
} |
1005 |
return super.isFocusControl (); |
1024 |
return super.isFocusControl (); |
1006 |
} |
1025 |
} |
|
|
1026 |
boolean isParentScrolling(Control scrollableParent) { |
1027 |
Control parent = this.getParent(); |
1028 |
while (parent != null) { |
1029 |
if (parent.equals(scrollableParent)) |
1030 |
return true; |
1031 |
parent = parent.getParent(); |
1032 |
} |
1033 |
return false; |
1034 |
} |
1007 |
void internalLayout (boolean changed) { |
1035 |
void internalLayout (boolean changed) { |
1008 |
if (isDropped ()) dropDown (false); |
1036 |
if (isDropped ()) dropDown (false); |
1009 |
Rectangle rect = getClientArea (); |
1037 |
Rectangle rect = getClientArea (); |