Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » TraverseListener
TraverseListener [message #464807] Wed, 30 November 2005 06:07 Go to next message
Jeff Yuan is currently offline Jeff YuanFriend
Messages: 34
Registered: July 2009
Member
Hi,
I'm trying to implement a feature where in a table, when you press the
arrow keys (up or down) it goes to the next row selects the data and does
something with it. However, when I try to get selection (by
getSelection()[0].getData()) it always returns the previous row's
information.

For example, say I'm currently at row 1, and I press down arrow key. The
selection goes to row 2 now. When I get the current selection in the
attached TraverseListener, it returns the data for row 1. So there is
always a phase difference of 1 in the selection. Can anyone give some
tips as to how I may address this?

Thanks.
Re: TraverseListener [message #464821 is a reply to message #464807] Wed, 30 November 2005 14:29 Go to previous messageGo to next message
Veronika Irvine is currently offline Veronika IrvineFriend
Messages: 1272
Registered: July 2009
Senior Member
The arrow keys already select the next item in a table, you do not need to
override the traversal behaviour to achieve this. Instead of trying to do
this in a Traverse listener why not do it in a Selection listener?

The reason you are seeing the old selection is because in the Traverse
event, the operating system has not yet processed the arrow key event and
has not yet assigned the new selection.

"zinc" <zincsterio@yahoo.com> wrote in message
news:0f3cd02ea853877e3e1aef9c61a4b29a$1@www.eclipse.org...
> Hi,
> I'm trying to implement a feature where in a table, when you press the
> arrow keys (up or down) it goes to the next row selects the data and does
> something with it. However, when I try to get selection (by
> getSelection()[0].getData()) it always returns the previous row's
> information.
>
> For example, say I'm currently at row 1, and I press down arrow key. The
> selection goes to row 2 now. When I get the current selection in the
> attached TraverseListener, it returns the data for row 1. So there is
> always a phase difference of 1 in the selection. Can anyone give some
> tips as to how I may address this?
>
> Thanks.
>
Re: TraverseListener [message #464829 is a reply to message #464821] Wed, 30 November 2005 14:41 Go to previous messageGo to next message
Jeff Yuan is currently offline Jeff YuanFriend
Messages: 34
Registered: July 2009
Member
So would you suggest use KeyListener? The same problem seem to still
occur. I have the KeyListener detect for example when KeyCode is equal to
SWT.ARROW_DOWN and get selection, but the gotten selection still seems to
be the old one.
Re: TraverseListener [message #464860 is a reply to message #464829] Wed, 30 November 2005 19:12 Go to previous message
Veronika Irvine is currently offline Veronika IrvineFriend
Messages: 1272
Registered: July 2009
Senior Member
No, I would use SWT.Selection listener.

"zinc" <zincsterio@yahoo.com> wrote in message
news:5f0575c1cabeb59aa403d14ce5c34398$1@www.eclipse.org...
> So would you suggest use KeyListener? The same problem seem to still
> occur. I have the KeyListener detect for example when KeyCode is equal to
> SWT.ARROW_DOWN and get selection, but the gotten selection still seems to
> be the old one.
>
>
>
Previous Topic:printing AWT Graphics
Next Topic:Extra blanc row and column in SWT Table
Goto Forum:
  


Current Time: Fri Dec 27 03:32:30 GMT 2024

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

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

Back to the top