90
|
1 /*******************************************************************************
|
|
2 * Copyright (c) 2000, 2006 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 * Bill Baxter <wbaxter> at gmail com
|
|
12 *******************************************************************************/
|
|
13 module snippets.canvas.Snippet290;
|
|
14
|
|
15 /*
|
|
16 * Canvas snippet: ignore 2nd mouse up event after double-click
|
|
17 *
|
|
18 * For a list of all SWT example snippets see
|
|
19 * http://www.eclipse.org/swt/snippets/
|
|
20 */
|
|
21
|
|
22 import dwt.widgets.Display;
|
|
23 import dwt.widgets.Shell;
|
|
24 import dwt.events.MouseEvent;
|
|
25 import dwt.events.MouseAdapter;
|
|
26
|
|
27 import tango.io.Stdout;
|
|
28
|
|
29 void main() {
|
|
30 final Display display = new Display();
|
|
31 final Shell shell = new Shell(display);
|
|
32 shell.addMouseListener(new class MouseAdapter {
|
|
33 public void mouseUp(MouseEvent e) {
|
|
34 if (e.count == 1) {
|
|
35 Stdout("Mouse up").newline;
|
|
36 }
|
|
37 }
|
|
38 public void mouseDoubleClick(MouseEvent e) {
|
|
39 Stdout("Double-click").newline;
|
|
40 }
|
|
41 });
|
|
42 shell.setBounds(10, 10, 200, 200);
|
|
43 shell.open ();
|
|
44 while (!shell.isDisposed()) {
|
|
45 if (!display.readAndDispatch()) display.sleep();
|
|
46 }
|
|
47 display.dispose();
|
|
48 }
|
|
49
|