views:

160

answers:

1

Hi

I'm using SWT Text component. Do someone know how can I prevent copy/paste operation for the Text component.

Thanks Subha

A: 

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).

Rusty