Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » How to capture ENTER when a default button is defined
How to capture ENTER when a default button is defined [message #453218] Fri, 01 April 2005 03:11 Go to next message
Rod Bailey is currently offline Rod BaileyFriend
Messages: 5
Registered: July 2009
Junior Member
Can anyone advise how I might produce the following effect:

I have a Composite, which has numerous child widgets, one of which is a
Table, another of which is a Button.
The Button is defined as the default button for the Composite, so that
pressing ENTER always triggers this Button.
I want to introduce an exception to this behaviour. Whenever the Table, or a
row within it, has the focus, I want to
do something else when ENTER is pressed (in particular, display more
information about the row currently selected).

But I can't find a way to intercept the ENTER key when the Table has the
focus. I tried adding a KeyListener to the Table, but the KeyListener is
never called when ENTER is pressed.

At the moment, the only thing I can think of is to add a FocusListener to
the Table, remove the Button as the default button when the Table receives
focus, and make it the default again when the Table loses Focus.

Is there a better way than this?
Re: How to capture ENTER when a default button is defined [message #453230 is a reply to message #453218] Fri, 01 April 2005 12:52 Go to previous message
Steve Northover is currently offline Steve NorthoverFriend
Messages: 1636
Registered: July 2009
Senior Member
You can use the SWT.Traverse event. Modify this snippet to look for
SWT.TRAVERSE_RETURN and it should WORKFORYOU.

http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt.sni ppets/src/org/eclipse/swt/snippets/Snippet127.java?rev=HEAD& amp;content-type=text/vnd.viewcvs-markup

"Rod Bailey" <mr.rod.bailey@bigpond.com> wrote in message
news:d2ie7o$ldd$1@news.eclipse.org...
> Can anyone advise how I might produce the following effect:
>
> I have a Composite, which has numerous child widgets, one of which is a
> Table, another of which is a Button.
> The Button is defined as the default button for the Composite, so that
> pressing ENTER always triggers this Button.
> I want to introduce an exception to this behaviour. Whenever the Table, or
a
> row within it, has the focus, I want to
> do something else when ENTER is pressed (in particular, display more
> information about the row currently selected).
>
> But I can't find a way to intercept the ENTER key when the Table has the
> focus. I tried adding a KeyListener to the Table, but the KeyListener is
> never called when ENTER is pressed.
>
> At the moment, the only thing I can think of is to add a FocusListener to
> the Table, remove the Button as the default button when the Table receives
> focus, and make it the default again when the Table loses Focus.
>
> Is there a better way than this?
>
>
>
Previous Topic:Updating TableViewer input
Next Topic:event between display and system?
Goto Forum:
  


Current Time: Tue Dec 10 21:22:41 GMT 2019

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

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

Back to the top