28
|
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 org.eclipse.swt.snippets.Snippet14;
|
|
14
|
|
15 /*
|
|
16 * Control example snippet: detect mouse enter, exit and hover events
|
|
17 *
|
|
18 * For a list of all SWT example snippets see
|
|
19 * http://www.eclipse.org/swt/snippets/
|
|
20 */
|
|
21 import org.eclipse.swt.SWT;
|
|
22 import org.eclipse.swt.widgets.Display;
|
|
23 import org.eclipse.swt.widgets.Event;
|
|
24 import org.eclipse.swt.widgets.Listener;
|
|
25 import org.eclipse.swt.widgets.Shell;
|
|
26
|
|
27 import java.lang.all;
|
|
28
|
112
|
29 version(Tango){
|
|
30 import tango.io.Stdout;
|
|
31 } else { // Phobos
|
|
32 import std.stdio;
|
|
33 }
|
28
|
34
|
|
35 void main (String [] args) {
|
|
36 Display display = new Display ();
|
|
37 Shell shell = new Shell (display);
|
|
38 shell.setSize (100, 100);
|
|
39 shell.addListener (SWT.MouseEnter, new class() Listener{
|
|
40 public void handleEvent (Event e) {
|
112
|
41 version(Tango){
|
|
42 Stdout("ENTER\n");
|
|
43 Stdout.flush();
|
|
44 } else { // Phobos
|
|
45 writeln("ENTER");
|
|
46 }
|
28
|
47 }
|
|
48 });
|
|
49 shell.addListener (SWT.MouseExit, new class() Listener{
|
|
50 public void handleEvent (Event e) {
|
112
|
51 version(Tango){
|
|
52 Stdout("EXIT\n");
|
|
53 Stdout.flush();
|
|
54 } else { // Phobos
|
|
55 writeln("EXIT");
|
|
56 }
|
28
|
57 }
|
|
58 });
|
|
59 shell.addListener (SWT.MouseHover, new class() Listener{
|
|
60 public void handleEvent (Event e) {
|
112
|
61 version(Tango){
|
|
62 Stdout("HOVER\n");
|
|
63 Stdout.flush();
|
|
64 } else { // Phobos
|
|
65 writeln("HOVER");
|
|
66 }
|
28
|
67 }
|
|
68 });
|
|
69 shell.open ();
|
|
70 while (!shell.isDisposed()) {
|
|
71 if (!display.readAndDispatch ()) display.sleep ();
|
|
72 }
|
|
73 display.dispose ();
|
|
74 }
|