Mercurial > projects > dwt-samples
comparison snippets/combo/Snippet24.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 combo.Snippet24; | |
14 | |
15 /* | |
16 * example snippet: detect CR in a text or combo control (default selection) | |
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.widgets.Combo; | |
23 import dwt.widgets.Display; | |
24 import dwt.widgets.Event; | |
25 import dwt.widgets.Listener; | |
26 import dwt.widgets.Shell; | |
27 import dwt.widgets.Text; | |
28 import dwt.layout.RowLayout; | |
29 | |
30 import dwt.dwthelper.utils; | |
31 import tango.io.Stdout; | |
32 | |
33 void main (String [] args) { | |
34 Display display = new Display (); | |
35 Shell shell = new Shell (display); | |
36 shell.setLayout (new RowLayout ()); | |
37 Combo combo = new Combo (shell, DWT.NONE); | |
38 combo.setItems (["A-1", "B-1", "C-1"]); | |
39 Text text = new Text (shell, DWT.SINGLE | DWT.BORDER); | |
40 text.setText ("some text"); | |
41 combo.addListener (DWT.DefaultSelection, new class() Listener{ | |
42 public void handleEvent (Event e) { | |
43 Stdout(e.widget.toString() ~ " - Default Selection\n"); | |
44 } | |
45 }); | |
46 text.addListener (DWT.DefaultSelection, new class() Listener{ | |
47 public void handleEvent (Event e) { | |
48 Stdout(e.widget.toString() ~ " - Default Selection\n"); | |
49 } | |
50 }); | |
51 shell.pack (); | |
52 shell.open (); | |
53 while (!shell.isDisposed()) { | |
54 if (!display.readAndDispatch ()) display.sleep (); | |
55 } | |
56 display.dispose (); | |
57 } |