Search in sources :

Example 1 with DoubleField

use of de.jaret.util.ui.DoubleField in project translationstudio8 by heartsome.

the class DoubleCellEditor method createControl.

/**
     * Create and setup the control.
     * 
     * @param table parent for the control
     */
private void createControl(JaretTable table) {
    if (_text == null) {
        _table = table;
        _text = new Text(table, SWT.BORDER | SWT.RIGHT);
        _doubleField = new DoubleField();
        _doubleField.setText(_text);
        _text.addKeyListener(new KeyListener() {

            public void keyPressed(KeyEvent event) {
                if (event.keyCode == SWT.TAB) {
                    event.doit = false;
                    stopEditing(true);
                    _table.forceFocus();
                    _table.focusRight();
                } else if (event.keyCode == SWT.CR) {
                    event.doit = false;
                    stopEditing(true);
                    _table.forceFocus();
                    _table.focusDown();
                } else if (event.keyCode == SWT.ESC) {
                    event.doit = false;
                    stopEditing(false);
                    _column.setValue(_row, _oldVal);
                    _table.forceFocus();
                }
            }

            public void keyReleased(KeyEvent arg0) {
            }
        });
        _text.addFocusListener(this);
    }
}
Also used : KeyEvent(org.eclipse.swt.events.KeyEvent) Text(org.eclipse.swt.widgets.Text) KeyListener(org.eclipse.swt.events.KeyListener) DoubleField(de.jaret.util.ui.DoubleField)

Aggregations

DoubleField (de.jaret.util.ui.DoubleField)1 KeyEvent (org.eclipse.swt.events.KeyEvent)1 KeyListener (org.eclipse.swt.events.KeyListener)1 Text (org.eclipse.swt.widgets.Text)1