Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community ForumsHandle return key as tab key
https://www.eclipse.org/forums/index.php/mv/msg/37190/120875/#msg_120875
I want to handle the return key as if it be a tab key, i.e. every time
the user hit the return key the focus goes to the next control in the shell.
In SWT, I created a TraverseListener and changed the e.detail in
keyTraversed event, and it functions.
The same code in RWT does not function.
How can I send a key event to the active widget?
Or how can I simulate the tab key behavior?
Thanks
Enrico
Here is the snippet:
public class RapTest implements IEntryPoint {
private Display d;
private Shell s;
@Override
public int createUI() {
d = new Display();
s = new Shell(d);
s.setBounds(0, 0, 800, 600);
Text t1 = new Text(s, SWT.BORDER);
Text t2 = new Text(s, SWT.BORDER);
}]]>Enrico Zanaga2009-02-06T14:13:46-00:00Re: Handle return key as tab key
https://www.eclipse.org/forums/index.php/mv/msg/37190/121045/#msg_121045
the current TraverseListeners implementation only covers the needs
of cell editors.
I don't see how turning return key events into tab key events could
be achieved in RAP with reasonable effort.
Regards,
Rüdiger
Enrico Zanaga wrote:
> Hi,
>
> I want to handle the return key as if it be a tab key, i.e. every time
> the user hit the return key the focus goes to the next control in the
> shell.
>
> In SWT, I created a TraverseListener and changed the e.detail in
> keyTraversed event, and it functions.
> The same code in RWT does not function.
>
> How can I send a key event to the active widget?
> Or how can I simulate the tab key behavior?
>
> Thanks
> Enrico
>
> Here is the snippet:
>
> public class RapTest implements IEntryPoint {
>
> private Display d;
> private Shell s;
>
> @Override
> public int createUI() {
> d = new Display();
> s = new Shell(d);
> s.setBounds(0, 0, 800, 600);
>
> Text t1 = new Text(s, SWT.BORDER);
> Text t2 = new Text(s, SWT.BORDER);
>
> t1.setBounds(020, 40, 80, 20);
> t2.setBounds(120, 40, 80, 20);
>
> TraverseListener tl = new TraverseListener() {
>
> @Override
> public void keyTraversed(TraverseEvent e) {
> if( e.detail == SWT.TRAVERSE_RETURN ) {
> if( (e.stateMask & SWT.SHIFT) != 0 )
> e.detail = SWT.TRAVERSE_TAB_PREVIOUS;
> else
> e.detail = SWT.TRAVERSE_TAB_NEXT;
> e.doit = true;
> }
> }
>
> };
>
> t1.addTraverseListener(tl);
> t2.addTraverseListener(tl);
>
> s.open();
>
> while( !s.isDisposed() )
> if( !d.readAndDispatch() )
> d.sleep();
> d.dispose();
>
> return 0;
> }
>
> }]]>Rüdiger Herrmann2009-02-08T18:02:17-00:00Re: Handle return key as tab key
https://www.eclipse.org/forums/index.php/mv/msg/37190/121062/#msg_121062
have you any trick for sending a key event to the client?
Thanks
Enrico
Rüdiger Herrmann ha scritto:
> Enrico,
>
> the current TraverseListeners implementation only covers the needs of
> cell editors.
> I don't see how turning return key events into tab key events could be
> achieved in RAP with reasonable effort.
>
> Regards,
> Rüdiger
>
> Enrico Zanaga wrote:
>> Hi,
>>
>> I want to handle the return key as if it be a tab key, i.e. every time
>> the user hit the return key the focus goes to the next control in the
>> shell.
>>
>> In SWT, I created a TraverseListener and changed the e.detail in
>> keyTraversed event, and it functions.
>> The same code in RWT does not function.
>>
>> How can I send a key event to the active widget?
>> Or how can I simulate the tab key behavior?
>>
>> Thanks
>> Enrico
>>
>> Here is the snippet:
>>
>> public class RapTest implements IEntryPoint {
>>
>> private Display d;
>> private Shell s;
>>
>> @Override
>> public int createUI() {
>> d = new Display();
>> s = new Shell(d);
>> s.setBounds(0, 0, 800, 600);
>>
>> Text t1 = new Text(s, SWT.BORDER);
>> Text t2 = new Text(s, SWT.BORDER);
>>
>> t1.setBounds(020, 40, 80, 20);
>> t2.setBounds(120, 40, 80, 20);
>>
>> TraverseListener tl = new TraverseListener() {
>>
>> @Override
>> public void keyTraversed(TraverseEvent e) {
>> if( e.detail == SWT.TRAVERSE_RETURN ) {
>> if( (e.stateMask & SWT.SHIFT) != 0 )
>> e.detail = SWT.TRAVERSE_TAB_PREVIOUS;
>> else
>> e.detail = SWT.TRAVERSE_TAB_NEXT;
>> e.doit = true;
>> }
>> }
>>
>> };
>>
>> t1.addTraverseListener(tl);
>> t2.addTraverseListener(tl);
>>
>> s.open();
>>
>> while( !s.isDisposed() )
>> if( !d.readAndDispatch() )
>> d.sleep();
>> d.dispose();
>>
>> return 0;
>> }
>>
>> }
>]]>Enrico Zanaga2009-02-09T08:53:49-00:00