Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[platform-swt-dev] setting focus to cell-editor

I know that this is the SWT-Maillinglist but I tried more than once at the newsgroups but nobody is willing to answer this question there :-).

I've just started to implement a key-listener who has the following purpose:
When the TAB-key is pressed I want to go to the next column in the TableViewer and start editing it. I'm already catching the TAB event but I somehow couldn't open the editor in the next column what am I doing wrong here. It must have missed something very basically or the whole approach I'm taking is completely wrong?

See also: https://bugs.eclipse.org/bugs/show_bug.cgi?id=75114

Although in my understanding when using SWT/JFace as an input-gui e.g. to a database this feature is mandatory its not part of it until now.

---------------------------8<---------------------------
public class TraversalTest implements TraverseListener {
    private int columnIdx = 0;
    private TableViewer viewer;

    public TraversalTest( TableViewer viewer, int columnIdx ) {
        this.columnIdx = columnIdx;
        this.viewer = viewer;
    }

    /* (non-Javadoc)
     * @see
org.eclipse.swt.events.TraverseListener#keyTraversed(org.eclipse.swt.events.TraverseEvent)
     */
    public void keyTraversed(TraverseEvent e) {
        // TODO Auto-generated method stub
            if( e.detail == SWT.TRAVERSE_TAB_PREVIOUS || e.detail ==
SWT.TRAVERSE_TAB_NEXT ) {
                if( viewer != null ) {
                    CellEditor[] editors = viewer.getCellEditors();
                    e.doit = false;
if( columnIdx > 0 && e.detail == SWT.TRAVERSE_TAB_PREVIOUS ) {
                        // editors[columnIdx].deactivate();
                        // editors[columnIdx-1].activate();
                        // editors[columnIdx-1].setFocus();
                        // editors[columnIdx-1].getControl().forceFocus();
} else if( e.detail == SWT.TRAVERSE_TAB_NEXT && columnIdx+1
< editors.length ) {
                        // editors[columnIdx].deactivate();
                        // editors[columnIdx+1].activate();
                        // editors[columnIdx-1].setFocus();
                        // editors[columnIdx+1].getControl().forceFocus();
                    } else {
System.out.println("We reached start or end of row");
                    }
                } else {
                    System.out.println("I have no viewer");
                }
            } else {
System.out.println("No need to cancle its not a tab-event");
            }
    }
}
---------------------------8<---------------------------

Why isn't there a mailling list for JFace like there is this list for swt implementation details?


Tom


Back to the top