开发者

Disable copy paste in SWT Text Component

I'm using SWT Text component. Do someone know how can I prevent copy/p开发者_如何学编程aste operation for the Text component.

Thanks Subha


A crude way of doing this would be to disable the control-key modifier on the Text box.

    text.addKeyListener(new KeyListener() {

        @Override
        public void keyReleased(KeyEvent event) {

        }

        @Override
        public void keyPressed(KeyEvent event) {
            if (event.stateMask == 262144) {
                event.doit = false;
            }

        }
    });

Plus you may also want to disable the right click on the text box (use a MouseListener with the same trick).


I done this by simply setting my own menu with no menu items at all.

      ((Text) textFirstNameEntry).setMenu(new Menu(shell, 0));
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜