Search in sources :

Example 1 with KeyEvent

use of org.eclipse.draw2d.KeyEvent in project yamcs-studio by yamcs.

the class ScrollbarFigure method initializeListeners.

/**
 */
private void initializeListeners() {
    addKeyListener(new KeyListener() {

        @Override
        public void keyPressed(KeyEvent ke) {
            if ((ke.keycode == SWT.ARROW_UP && !isHorizontal()) || (ke.keycode == SWT.ARROW_LEFT && isHorizontal()))
                stepUp();
            else if ((ke.keycode == SWT.ARROW_DOWN && !isHorizontal()) || (ke.keycode == SWT.ARROW_RIGHT && isHorizontal()))
                stepDown();
            else if ((ke.keycode == SWT.PAGE_DOWN && !isHorizontal()) || (ke.keycode == SWT.PAGE_UP && isHorizontal()))
                pageDown();
            else if ((ke.keycode == SWT.PAGE_UP && !isHorizontal()) || (ke.keycode == SWT.PAGE_DOWN && isHorizontal()))
                pageUp();
        }

        @Override
        public void keyReleased(KeyEvent ke) {
        }
    });
    addFocusListener(new FocusListener() {

        @Override
        public void focusGained(FocusEvent fe) {
            repaint();
        }

        @Override
        public void focusLost(FocusEvent fe) {
            repaint();
        }
    });
}
Also used : KeyEvent(org.eclipse.draw2d.KeyEvent) KeyListener(org.eclipse.draw2d.KeyListener) FocusListener(org.eclipse.draw2d.FocusListener) FocusEvent(org.eclipse.draw2d.FocusEvent)

Aggregations

FocusEvent (org.eclipse.draw2d.FocusEvent)1 FocusListener (org.eclipse.draw2d.FocusListener)1 KeyEvent (org.eclipse.draw2d.KeyEvent)1 KeyListener (org.eclipse.draw2d.KeyListener)1