1 #!/usr/bin/env dub 2 /+ 3 dub.sdl: 4 name "snippet4" 5 dependency "dwt" path="../../../../../../" version="*" 6 libs \ 7 "atk-1.0" \ 8 "cairo" \ 9 "dl" \ 10 "fontconfig" \ 11 "gdk-x11-2.0" \ 12 "gdk_pixbuf-2.0" \ 13 "gio-2.0" \ 14 "glib-2.0" \ 15 "gmodule-2.0" \ 16 "gobject-2.0" \ 17 "gthread-2.0" \ 18 "gtk-x11-2.0" \ 19 "pango-1.0" \ 20 "pangocairo-1.0" \ 21 "X11" \ 22 "Xcomposite" \ 23 "Xcursor" \ 24 "Xdamage" \ 25 "Xext" \ 26 "Xfixes" \ 27 "Xi" \ 28 "Xinerama" \ 29 "Xrandr" \ 30 "Xrender" \ 31 "Xtst" \ 32 platform="linux" 33 +/ 34 /******************************************************************************* 35 * Copyright (c) 2000, 2016 IBM Corporation and others. 36 * All rights reserved. This program and the accompanying materials 37 * are made available under the terms of the Eclipse Public License v1.0 38 * which accompanies this distribution, and is available at 39 * http://www.eclipse.org/legal/epl-v10.html 40 * 41 * Contributors: 42 * IBM Corporation - initial API and implementation 43 * Lars Vogel <Lars.Vogel@vogella.com> - Bug 502845 44 * D Port: 45 * alice <stigma@disroot.org> 46 *******************************************************************************/ 47 module org.eclipse.swt.snippets.Snippet4; 48 49 /* 50 * Shell example snippet: prevent escape from closing a dialog 51 * 52 * For a list of all SWT example snippets see 53 * http://www.eclipse.org/swt/snippets/ 54 */ 55 import org.eclipse.swt.events.SelectionAdapter; 56 57 import org.eclipse.swt.all; 58 import org.eclipse.swt.graphics.all; 59 import org.eclipse.swt.widgets.all; 60 61 void main(string[] args) { 62 Display display = new Display(); 63 Shell shell = new Shell(display); 64 Button b = new Button(shell, SWT.PUSH); 65 b.setText("Open Dialog ..."); 66 b.pack(); 67 Rectangle clientArea = shell.getClientArea(); 68 b.setLocation(clientArea.x + 10, clientArea.y + 10); 69 b.addSelectionListener(new class SelectionAdapter { 70 override void widgetSelected(SelectionEvent e) { 71 Shell dialog = new Shell(shell, SWT.DIALOG_TRIM); 72 dialog.addTraverseListener(new class TraverseListener { 73 override void keyTraversed(TraverseEvent t) { 74 if (t.detail == SWT.TRAVERSE_ESCAPE) { 75 t.doit = false; 76 } 77 } 78 }); 79 dialog.open(); 80 } 81 override void widgetDefaultSelected(SelectionEvent e) {} 82 }); 83 shell.open(); 84 while (!shell.isDisposed()) { 85 if (!display.readAndDispatch()) display.sleep(); 86 } 87 display.dispose(); 88 }