Tamizh Tamizh - 5 months ago 21
Java Question

Select all (CTRL+A) option not present in SWT Text field

I am using an SWT application. I can't select all text in a text box or text area by Ctrl+A.

Is there any way to achieve this?

Answer
text.addKeyListener(new KeyAdapter() {
    @Override
    public void keyPressed(KeyEvent e)
    {
        if (e.stateMask == SWT.CTRL && e.keyCode == 'a') {
            text.selectAll();
            e.doit = false;
        }
    }
});