Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Handle return key as tab key
Handle return key as tab key [message #120875] Fri, 06 February 2009 14:13 Go to next message
Enrico Zanaga is currently offline Enrico ZanagaFriend
Messages: 50
Registered: July 2009
Member
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;
}

}
Re: Handle return key as tab key [message #121045 is a reply to message #120875] Sun, 08 February 2009 18:02 Go to previous messageGo to next message
Rüdiger Herrmann is currently offline Rüdiger HerrmannFriend
Messages: 581
Registered: July 2009
Senior Member
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;
> }
>
> }
Re: Handle return key as tab key [message #121062 is a reply to message #121045] Mon, 09 February 2009 08:53 Go to previous message
Enrico Zanaga is currently offline Enrico ZanagaFriend
Messages: 50
Registered: July 2009
Member
Rüdiger,

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;
>> }
>>
>> }
>
Previous Topic:TextSizeDeterminationHandler sets and resets the size of a widget
Next Topic:no context menu on TableViewer
Goto Forum:
  


Current Time: Thu Apr 25 17:09:33 GMT 2024

Powered by FUDForum. Page generated in 0.03667 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top