Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 292413

Summary: [GTK] EraseItem and PaintItem events are missing SWT.FOCUSED bit
Product: [Eclipse Project] Platform Reporter: Grant Gayed <grant_gayed>
Component: SWTAssignee: Platform-SWT-Inbox <platform-swt-inbox>
Status: RESOLVED WORKSFORME QA Contact:
Severity: normal    
Priority: P3 CC: ericwill, pinnamur
Version: 3.6Keywords: triaged
Target Milestone: ---   
Hardware: PC   
OS: Linux-GTK   
Whiteboard:

Description Grant Gayed CLA 2009-10-15 10:49:49 EDT
- tried with gtk+ 2.4 and 2.10, with the latest swt
- there are references to SWT.FOCUSED in Table and Tree, so maybe this used to work?

- run the snippet below
- item focus can be moved with Ctrl+ArrowUp/ArrowDown
- the EraseItem and PaintItem events are received but their detail field never contains the SWT.FOCUSED bit

public static void main(String[] args) {
    final Display display = new Display();
    final Shell shell = new Shell(display);
    shell.setBounds(10,10,200,200);
    shell.setLayout(new FillLayout());
    final Tree tree = new Tree(shell, SWT.MULTI);
    for (int i = 0; i < 9; i++) {
        new TreeItem(tree, SWT.NONE).setText("item " + i);
    }
    tree.addListener(SWT.EraseItem, new Listener() {
        public void handleEvent(Event event) {
            System.out.println("EraseItem event");
            if ((event.detail & SWT.FOCUSED) != 0) {
                System.out.println("item has focus: " + ((TreeItem)event.item).getText());
            }
        }
    });
    tree.addListener(SWT.PaintItem, new Listener() {
        public void handleEvent(Event event) {
            System.out.println("PaintItem event");
            if ((event.detail & SWT.FOCUSED) != 0) {
                System.out.println("item has focus: " + ((TreeItem)event.item).getText());
            }
        }
    });
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) display.sleep();
    }
    display.dispose();
}
Comment 1 Eric Williams CLA 2016-10-18 12:17:03 EDT
This bug is still reproducible.
Comment 2 Eric Williams CLA 2018-03-22 12:00:10 EDT
Hmm, undoing some of the changes to bug 393724 fixes this. I'll have to test it further though.
Comment 3 Eric Williams CLA 2018-03-22 15:02:48 EDT
Oops, I misread the bug report. SWT on GTK3.22 has the proper behaviour -- closing this ticket.