Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 142981 - [CCombo] CCombo doesn't lose focus
Summary: [CCombo] CCombo doesn't lose focus
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P3 major (vote)
Target Milestone: 3.4 M6   Edit
Assignee: Duong Nguyen CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 108431
  Show dependency tree
 
Reported: 2006-05-22 08:49 EDT by Krzysztof Michalski CLA
Modified: 2014-02-06 01:47 EST (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Krzysztof Michalski CLA 2006-05-22 08:49:16 EDT
There is a difference in loosing focus on Text and CCombo controls. CCombo don't notify their listeners when focus lost. For example I have example with CCombo widget as below:

package org.eclipse.jface.viewers.tests.bug108431;

import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CCombo;
import org.eclipse.swt.events.FocusEvent;
import org.eclipse.swt.events.FocusListener;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class CComboTest {

    public static void main(String[] args) {
        Display display = new Display();
        Shell shell = new Shell(display);
        shell.setSize(300, 150);
        shell.setLayout(new FillLayout());

        CCombo combo = new CCombo(shell, SWT.READ_ONLY);
        combo.add("row1");
        combo.add("row2");
        combo.add("row3");
        combo.addFocusListener(new FocusListener() {

            public void focusGained(FocusEvent e) {
                System.out.println("Gained");
            }
            public void focusLost(FocusEvent e) {
                System.out.println("Lost");
                
            }});

        shell.open();

        while (!shell.isDisposed())
        {
            if (!display.readAndDispatch())
                display.sleep();
        }
        display.dispose();        
        
    }
}

- make a change in the ccombo(for example by traverse key up or down), but do not give <enter> or mouseclicks
- select main window of another program running (not this Eclipse instance)
- the changed ccombo don't notify his listeners(This control doesn't lose focus)

When you do the same on a Text, the listener are notified when focus lost.
Bug 108431 depend on it because they don't be notify when focus lost.
Comment 1 Steve Northover CLA 2008-01-14 16:50:46 EST
I believe we fixed this.  Duong to retest.
Comment 2 Duong Nguyen CLA 2008-01-21 18:49:14 EST
No. This is not fixed.
Comment 3 Steve Northover CLA 2008-02-20 09:45:31 EST
Duong, please get to the bottom of this.
Comment 4 Duong Nguyen CLA 2008-03-12 14:39:26 EDT
The problem is that we can't tell the difference between a Shell focusLost event when the CCombo popup list is shown or when another application is selected and the Shell really lost focus.

I tried several workarounds but the one that works best on all platforms is to defer the focus lost in an asyncExec. When focus is really lost, the focus control is null and isn't one of the components that makes up the ccombo (eg. text, list or button).

Fixed > 080312
Comment 5 deepak patwal CLA 2014-02-06 01:47:29 EST
Hi,

We are facing the same problem.

On clicking the combo box it opens normally but while moving the mouse from the combo box(focus out) it is not getting closed unless mouse button is pressed on the other control or shell.

We are using eclipse : 3.7.2
environment : solaris

Regards,
Deepak Patwal