How to capture ENTER when a default button is defined [message #453218] |
Fri, 01 April 2005 03:11 |
Rod Bailey 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 |
Steve Northover 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?
>
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.02818 seconds