Mercurial > projects > dwt-samples
comparison snippets/control/Snippet127.d @ 119:9a1be6ff19a2
More snippets, thanks to Tom D.
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sun, 20 Jul 2008 15:26:06 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
118:7b1c122b4128 | 119:9a1be6ff19a2 |
---|---|
1 /******************************************************************************* | |
2 * Copyright (c) 2000, 2004 IBM Corporation and others. | |
3 * All rights reserved. This program and the accompanying materials | |
4 * are made available under the terms of the Eclipse Public License v1.0 | |
5 * which accompanies this distribution, and is available at | |
6 * http://www.eclipse.org/legal/epl-v10.html | |
7 * | |
8 * Contributors: | |
9 * IBM Corporation - initial API and implementation | |
10 * D Port: | |
11 * Thomas Demmer <t_demmer AT web DOT de> | |
12 *******************************************************************************/ | |
13 module control.Snippet127; | |
14 | |
15 /* | |
16 * Control example snippet: prevent Tab from traversing out of a control | |
17 * | |
18 * For a list of all SWT example snippets see | |
19 * http://www.eclipse.org/swt/snippets/ | |
20 */ | |
21 import dwt.DWT; | |
22 import dwt.events.TraverseEvent; | |
23 import dwt.events.TraverseListener; | |
24 import dwt.widgets.Button; | |
25 import dwt.widgets.Display; | |
26 import dwt.widgets.Event; | |
27 import dwt.widgets.Listener; | |
28 import dwt.widgets.Shell; | |
29 import dwt.layout.RowLayout; | |
30 | |
31 import dwt.dwthelper.utils; | |
32 | |
33 void main (String [] args) { | |
34 Display display = new Display (); | |
35 Shell shell = new Shell (display); | |
36 shell.setLayout(new RowLayout ()); | |
37 Button button1 = new Button(shell, DWT.PUSH); | |
38 button1.setText("Can't Traverse"); | |
39 button1.addTraverseListener(new class() TraverseListener{ | |
40 public void keyTraversed(TraverseEvent e) { | |
41 switch (e.detail) { | |
42 case DWT.TRAVERSE_TAB_NEXT: | |
43 case DWT.TRAVERSE_TAB_PREVIOUS: { | |
44 e.doit = false; | |
45 } | |
46 } | |
47 } | |
48 }); | |
49 Button button2 = new Button (shell, DWT.PUSH); | |
50 button2.setText("Can Traverse"); | |
51 shell.pack (); | |
52 shell.open(); | |
53 while (!shell.isDisposed ()) { | |
54 if (!display.readAndDispatch ()) display.sleep (); | |
55 } | |
56 display.dispose (); | |
57 } | |
58 |