views:

206

answers:

2

How do I prevent a multi-line text field from "stealing" tab-key presses?

I mean: I'd like to use TAB to cycle between the elements of a window, but when I enter the multiline text, TAB becomes a "normal" key, and simply inserts tabulators into the text I'm typing.

How do I handle this? Should I write some custom listener, or can I change the behaviour of the component by using an SWT constant?

+2  A: 

Add a keystroke listener to the textfield or textarea and implement a special handler for TAB. I've seen this 'tab catching' on Swing applications too and it's usually annoying.

You could offer another handler for Shift-TAB which then would insert a \t, if you still want to allow tabs in the textfield.

Andreas_D
It works, thanks a lot.
G B