File tree Expand file tree Collapse file tree 1 file changed +16
-5
lines changed
durian-swt/src/main/java/com/diffplug/common/swt Expand file tree Collapse file tree 1 file changed +16
-5
lines changed Original file line number Diff line number Diff line change @@ -54,6 +54,7 @@ public class Shells {
54
54
private boolean positionIncludesTrim = true ;
55
55
private Map .Entry <Corner , Point > location = null ;
56
56
private boolean dontOpen = false ;
57
+ private boolean closeOnEscape = false ;
57
58
58
59
private Shells (int style , Coat coat ) {
59
60
this .style = style ;
@@ -184,6 +185,14 @@ public Shells setDontOpen(boolean dontOpen) {
184
185
return this ;
185
186
}
186
187
188
+ /**
189
+ * Determines whether the shell will close on escape, defaults to false.
190
+ */
191
+ public Shells setCloseOnEscape (boolean closeOnEscape ) {
192
+ this .closeOnEscape = closeOnEscape ;
193
+ return this ;
194
+ }
195
+
187
196
/** Opens the shell on this parent shell. */
188
197
public Shell openOn (Shell parent ) {
189
198
Preconditions .checkNotNull (parent );
@@ -352,11 +361,13 @@ private void setupShell(Shell shell) {
352
361
shell .setAlpha (alpha );
353
362
}
354
363
// disable close on ESCAPE
355
- shell .addListener (SWT .Traverse , e -> {
356
- if (e .detail == SWT .TRAVERSE_ESCAPE ) {
357
- e .doit = false ;
358
- }
359
- });
364
+ if (!closeOnEscape ) {
365
+ shell .addListener (SWT .Traverse , e -> {
366
+ if (e .detail == SWT .TRAVERSE_ESCAPE ) {
367
+ e .doit = false ;
368
+ }
369
+ });
370
+ }
360
371
// find the composite we're going to draw on
361
372
coat .putOn (shell );
362
373
You can’t perform that action at this time.
0 commit comments