From 7d3ba9344c953b6e6eb5b4547c5c6ab3984aacc7 Mon Sep 17 00:00:00 2001 From: Annika Karjakina Date: Mon, 30 Apr 2012 12:38:41 +0530 Subject: Bug 377155-CCombo dropdown list can go off the top screen bound --- .../common/org/eclipse/swt/custom/CCombo.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CCombo.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CCombo.java index f835690345..d2e5a87d22 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CCombo.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CCombo.java @@ -583,7 +583,17 @@ void dropDown (boolean drop) { int height = listRect.height + 2; int x = parentRect.x; int y = parentRect.y + comboSize.y; - if (y + height > displayRect.y + displayRect.height) y = parentRect.y - height; + if (y + height > displayRect.y + displayRect.height) { + int popUpwardsHeight = (parentRect.y - height < displayRect.y) ? parentRect.y - displayRect.y : height; + int popDownwardsHeight = displayRect.y + displayRect.height - y; + if (popUpwardsHeight > popDownwardsHeight) { + height = popUpwardsHeight; + y = parentRect.y - popUpwardsHeight; + } else { + height = popDownwardsHeight; + } + list.setSize (listRect.width, height - 2); + } if (x + width > displayRect.x + displayRect.width) x = displayRect.x + displayRect.width - listRect.width; popup.setBounds (x, y, width, height); popup.setVisible (true); -- cgit