Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Traversing out of a Text widget.
Traversing out of a Text widget. [message #448954] Sun, 16 January 2005 20:52 Go to next message
Eclipse UserFriend
Originally posted by: mmaercker.tripper-bullet.com

Hi,

What flags do I need to set or which events do I need to catch to use the
TAB key as a traversal impulse in the context of a Text widget?

I have a series of Text widgets in a window one below the other. When
SHIFT+TAB is pressed, the focus jumps from a Text widget to the one above
it. I would like a traversal in the opposite direction to take place when
the TAB tree is pressed alone (i.e. the standard traversal behaviour). I
can't stop the Text widget from interpreting the TAB key as a tab stop,
though. I've tried catching the key with a listener and then setting doit to
false which does keep a tab from being inserted but it does not lead to a
traversal event.


Any help greatly appreciated,

Martin Maerker
Re: Traversing out of a Text widget. [message #449143 is a reply to message #448954] Tue, 18 January 2005 18:58 Go to previous messageGo to next message
Steve Northover is currently offline Steve NorthoverFriend
Messages: 1636
Registered: July 2009
Senior Member
You should be able to modify snippet this snippet:


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

by setting "doit=true" for the traverse next case. This will cause
traversal to happen rather than the tab character to be inserted into the
control. NOTE: This should not be necessary if the widgets are single-line
text controls. If the widgets are multi-line, you might frustrate your
users because they will expect to be able to insert tab characters.

"Martin Maercker" <mmaercker@tripper-bullet.com> wrote in message
news:csek2t$fer$1@www.eclipse.org...
> Hi,
>
> What flags do I need to set or which events do I need to catch to use the
> TAB key as a traversal impulse in the context of a Text widget?
>
> I have a series of Text widgets in a window one below the other. When
> SHIFT+TAB is pressed, the focus jumps from a Text widget to the one above
> it. I would like a traversal in the opposite direction to take place when
> the TAB tree is pressed alone (i.e. the standard traversal behaviour). I
> can't stop the Text widget from interpreting the TAB key as a tab stop,
> though. I've tried catching the key with a listener and then setting doit
to
> false which does keep a tab from being inserted but it does not lead to a
> traversal event.
>
>
> Any help greatly appreciated,
>
> Martin Maerker
>
>
>
>
Re: Traversing out of a Text widget. [message #449146 is a reply to message #448954] Tue, 18 January 2005 19:13 Go to previous messageGo to next message
Veronika Irvine is currently offline Veronika IrvineFriend
Messages: 1272
Registered: July 2009
Senior Member
Use a traverse listener:

public static void main (String [] args) {
final Display display = new Display ();
Shell shell = new Shell (display);
shell.setLayout(new FillLayout());
Text t = new Text(shell, SWT.MULTI | SWT.WRAP);
t.setText("asd a sda da d ad as da sd adadadsasd");
t.addTraverseListener(new TraverseListener() {
public void keyTraversed(TraverseEvent e) {
if (e.detail == SWT.TRAVERSE_TAB_NEXT || e.detail ==
SWT.TRAVERSE_TAB_PREVIOUS) {
e.doit = true;
}
}
});
Button b = new Button(shell, SWT.PUSH);
b.setText("Button");
shell.open ();
while (!shell.isDisposed ()) {
if (!display.readAndDispatch ()) display.sleep ();
}
display.dispose ();
}

"Martin Maercker" <mmaercker@tripper-bullet.com> wrote in message
news:csek2t$fer$1@www.eclipse.org...
> Hi,
>
> What flags do I need to set or which events do I need to catch to use the
> TAB key as a traversal impulse in the context of a Text widget?
>
> I have a series of Text widgets in a window one below the other. When
> SHIFT+TAB is pressed, the focus jumps from a Text widget to the one above
> it. I would like a traversal in the opposite direction to take place when
> the TAB tree is pressed alone (i.e. the standard traversal behaviour). I
> can't stop the Text widget from interpreting the TAB key as a tab stop,
> though. I've tried catching the key with a listener and then setting doit
> to
> false which does keep a tab from being inserted but it does not lead to a
> traversal event.
>
>
> Any help greatly appreciated,
>
> Martin Maerker
>
>
>
>
Re: Traversing out of a Text widget. [message #449212 is a reply to message #448954] Wed, 19 January 2005 15:33 Go to previous message
Eclipse UserFriend
Originally posted by: mmaercker.tripper-bullet.com

Thanks Steve and Veronika,

your solution was exactly what I needed.


Best regards,

Martin Maercker


"Steve Northover" <steve_northover@ca.ibm.com> schrieb im Newsbeitrag
news:csjm8n$t3a$1@www.eclipse.org...
> You should be able to modify snippet this snippet:
>
>
>
http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt.sni ppets/src/org/ec
lipse/swt/snippets/Snippet127.java?rev=HEAD&content-type =text/vnd.viewcvs-ma
rkup
>
> by setting "doit=true" for the traverse next case. This will cause
> traversal to happen rather than the tab character to be inserted into the
> control. NOTE: This should not be necessary if the widgets are
single-line
> text controls. If the widgets are multi-line, you might frustrate your
> users because they will expect to be able to insert tab characters.


"Veronika Irvine" <veronika_irvine@oti.com> schrieb im Newsbeitrag
news:csjn5q$2ap$1@www.eclipse.org...
> Use a traverse listener:
>
> public static void main (String [] args) {
> final Display display = new Display ();
> Shell shell = new Shell (display);
> shell.setLayout(new FillLayout());
> Text t = new Text(shell, SWT.MULTI | SWT.WRAP);
> t.setText("asd a sda da d ad as da sd adadadsasd");
> t.addTraverseListener(new TraverseListener() {
> public void keyTraversed(TraverseEvent e) {
> if (e.detail == SWT.TRAVERSE_TAB_NEXT || e.detail
==
> SWT.TRAVERSE_TAB_PREVIOUS) {
> e.doit = true;
> }
> }
> });
> Button b = new Button(shell, SWT.PUSH);
> b.setText("Button");
> shell.open ();
> while (!shell.isDisposed ()) {
> if (!display.readAndDispatch ()) display.sleep ();
> }
> display.dispose ();
> }




"Martin Maercker" <mmaercker@tripper-bullet.com> schrieb im Newsbeitrag
news:csek2t$fer$1@www.eclipse.org...
> Hi,
>
> What flags do I need to set or which events do I need to catch to use the
> TAB key as a traversal impulse in the context of a Text widget?
>
> I have a series of Text widgets in a window one below the other. When
> SHIFT+TAB is pressed, the focus jumps from a Text widget to the one above
> it. I would like a traversal in the opposite direction to take place when
> the TAB tree is pressed alone (i.e. the standard traversal behaviour). I
> can't stop the Text widget from interpreting the TAB key as a tab stop,
> though. I've tried catching the key with a listener and then setting doit
to
> false which does keep a tab from being inserted but it does not lead to a
> traversal event.
>
>
> Any help greatly appreciated,
>
> Martin Maerker
>
>
>
>
Previous Topic:Swing/awt and SWT events compatibility
Next Topic:SWT HTML browser component
Goto Forum:
  


Current Time: Thu Apr 25 17:27:27 GMT 2024

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

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

Back to the top