SWT的--键盘事件处理

http://203.208.37.104/search?q=cache:RPzitXP5E8IJ:blog.csdn.net/wing5jface/archive/2005/01/16/255091.aspx+swt+%E9%94%AE%E7%9B%98%E4%BA%8B%E4%BB%B6%E5%A4%84%E7%90%86&hl=zh-CN&ct=clnk&cd=1&gl=cn&client=aff-cs-maxthon&st_usg=ALhdy29bKoqrRy3390GyBSVJTlmFvKNNBg



Color red = display.getSystemColor(SWT.COLOR_RED);
Font font = display.getSystemFont();
control.setFont(font)

Style
Description
========================
SWT.WRAP
Wrap the text to fit the visible area

SWT.LEFT
Left-align the label

SWT.CENTER
Center-align the label

SWT.RIGHT
Right-align the label

SWT.SEPARATOR
Draw a separator instead of text or an image

SWT.HORIZONTAL
Draw the separator horizontally

SWT.VERTICAL
Draw the separator vertically

SWT.SHADOW_IN
Draw the separator with a "shadow in" effect

SWT.SHADOW_OUT`
Draw the separator

Separators

键盘事件类型

SWT.KeyDown
A key was pressed

SWT.KeyUp
A key was released


KeyEvent
KeyListener (and KeyAdapter)
keyPressed(KeyEvent)

keyReleased(KeyEvent)



关于event中的character特殊键值

SWT.BS
退回 ('\b')

SWT.CR
回车 ('\r')

SWT.DEL
删除 ('\u007F')

SWT.ESC
ESC ('\u001B')

SWT.LF
换行 ('\n')

SWT.TAB
TAB跳格 ('\t')


SWT.CONTROL
  <Ctrl>同 SWT.CTRL

SWT.SHIFT
  <Shift>

SWT.ALT
  <Alt>



以下代码来自摘录
Listener listener = new Listener() {
        public void handleEvent(Event event) {
            String string =
                event.type == SWT.KeyDown ? "DOWN": "UP  ";
             if ((event.stateMask & SWT.CTRL) != 0)
                string += " CTRL";
            if ((event.stateMask & SWT.ALT) != 0)
                string += " ALT";
            if ((event.stateMask & SWT.SHIFT) != 0)
                string += " SHIFT";

           switch (event.character) {

                case 0: string += " '\\0'"; break;

                case SWT.BS: string += " '\\b'"; break;

                case SWT.CR: string += " '\\r'"; break;

                case SWT.DEL: string += " DEL"; break;

                case SWT.ESC: string += " ESC"; break;

                case SWT.LF: string += " '\\n'"; break;

                case SWT.TAB: string += " '\\t'";

                    break;

                default:

                    string += " '" + event.character + "'";

                    break;

            }


text.addListener(SWT.Modify, new Listener() {

        public void handleEvent(Event e) {

            modified[0] = true;

        }

    });

final ProgressBar bar =new ProgressBar(shell,SWT.NONE);

    bar.setSize(200, 32);
new Thread() {

        public void run() {

            for (int i = 0; i <= maximum; i++) {

                try {

                    Thread.sleep(100);

                } catch (Throwable th) {

                }

                final int index = i;

                display.asyncExec(new Runnable() {

                    public void run() {

                        bar.setSelection(index);

                    }

                });

            }

        }

    }.start();





。。。。。。。。。。

你可能感兴趣的:(thread,.net,cache,Blog,UP)