Lines 11-21
Link Here
|
11 |
package org.eclipse.swt.custom; |
11 |
package org.eclipse.swt.custom; |
12 |
|
12 |
|
13 |
|
13 |
|
14 |
import org.eclipse.swt.*; |
14 |
import org.eclipse.swt.SWT; |
15 |
import org.eclipse.swt.graphics.*; |
15 |
import org.eclipse.swt.SWTException; |
16 |
import org.eclipse.swt.events.*; |
16 |
import org.eclipse.swt.accessibility.ACC; |
17 |
import org.eclipse.swt.widgets.*; |
17 |
import org.eclipse.swt.accessibility.AccessibleAdapter; |
18 |
import org.eclipse.swt.accessibility.*; |
18 |
import org.eclipse.swt.accessibility.AccessibleControlAdapter; |
|
|
19 |
import org.eclipse.swt.accessibility.AccessibleControlEvent; |
20 |
import org.eclipse.swt.accessibility.AccessibleEvent; |
21 |
import org.eclipse.swt.accessibility.AccessibleTextAdapter; |
22 |
import org.eclipse.swt.accessibility.AccessibleTextEvent; |
23 |
import org.eclipse.swt.events.ModifyListener; |
24 |
import org.eclipse.swt.events.SelectionEvent; |
25 |
import org.eclipse.swt.events.SelectionListener; |
26 |
import org.eclipse.swt.graphics.Color; |
27 |
import org.eclipse.swt.graphics.Font; |
28 |
import org.eclipse.swt.graphics.GC; |
29 |
import org.eclipse.swt.graphics.Point; |
30 |
import org.eclipse.swt.graphics.Rectangle; |
31 |
import org.eclipse.swt.widgets.Button; |
32 |
import org.eclipse.swt.widgets.Composite; |
33 |
import org.eclipse.swt.widgets.Control; |
34 |
import org.eclipse.swt.widgets.Display; |
35 |
import org.eclipse.swt.widgets.Event; |
36 |
import org.eclipse.swt.widgets.Label; |
37 |
import org.eclipse.swt.widgets.Layout; |
38 |
import org.eclipse.swt.widgets.List; |
39 |
import org.eclipse.swt.widgets.Listener; |
40 |
import org.eclipse.swt.widgets.Menu; |
41 |
import org.eclipse.swt.widgets.Shell; |
42 |
import org.eclipse.swt.widgets.Text; |
43 |
import org.eclipse.swt.widgets.TypedListener; |
44 |
import org.eclipse.swt.widgets.Widget; |
19 |
|
45 |
|
20 |
/** |
46 |
/** |
21 |
* The CCombo class represents a selectable user interface object |
47 |
* The CCombo class represents a selectable user interface object |
Lines 40-46
Link Here
|
40 |
Shell popup; |
66 |
Shell popup; |
41 |
Button arrow; |
67 |
Button arrow; |
42 |
boolean hasFocus; |
68 |
boolean hasFocus; |
43 |
Listener listener, filter; |
69 |
Listener listener; |
44 |
Color foreground, background; |
70 |
Color foreground, background; |
45 |
Font font; |
71 |
Font font; |
46 |
|
72 |
|
Lines 106-120
Link Here
|
106 |
return; |
132 |
return; |
107 |
} |
133 |
} |
108 |
if (getShell () == event.widget) { |
134 |
if (getShell () == event.widget) { |
109 |
handleFocus (SWT.FocusOut); |
135 |
getDisplay().asyncExec(new Runnable() { |
110 |
} |
136 |
public void run() { |
111 |
} |
137 |
handleFocus (SWT.FocusOut); |
112 |
}; |
138 |
} |
113 |
filter = new Listener() { |
139 |
}); |
114 |
public void handleEvent(Event event) { |
140 |
|
115 |
Shell shell = ((Control)event.widget).getShell (); |
|
|
116 |
if (shell == CCombo.this.getShell ()) { |
117 |
handleFocus (SWT.FocusOut); |
118 |
} |
141 |
} |
119 |
} |
142 |
} |
120 |
}; |
143 |
}; |
Lines 122-134
Link Here
|
122 |
int [] comboEvents = {SWT.Dispose, SWT.Move, SWT.Resize}; |
145 |
int [] comboEvents = {SWT.Dispose, SWT.Move, SWT.Resize}; |
123 |
for (int i=0; i<comboEvents.length; i++) this.addListener (comboEvents [i], listener); |
146 |
for (int i=0; i<comboEvents.length; i++) this.addListener (comboEvents [i], listener); |
124 |
|
147 |
|
125 |
int [] textEvents = {SWT.KeyDown, SWT.KeyUp, SWT.MenuDetect, SWT.Modify, SWT.MouseDown, SWT.MouseUp, SWT.Traverse, SWT.FocusIn}; |
148 |
int [] textEvents = {SWT.KeyDown, SWT.KeyUp, SWT.MenuDetect, SWT.Modify, SWT.MouseDown, SWT.MouseUp, SWT.Traverse, SWT.FocusIn, SWT.FocusOut}; |
126 |
for (int i=0; i<textEvents.length; i++) text.addListener (textEvents [i], listener); |
149 |
for (int i=0; i<textEvents.length; i++) text.addListener (textEvents [i], listener); |
127 |
|
150 |
|
128 |
int [] arrowEvents = {SWT.Selection, SWT.FocusIn}; |
151 |
int [] arrowEvents = {SWT.Selection, SWT.FocusIn}; |
129 |
for (int i=0; i<arrowEvents.length; i++) arrow.addListener (arrowEvents [i], listener); |
152 |
for (int i=0; i<arrowEvents.length; i++) arrow.addListener (arrowEvents [i], listener); |
130 |
|
153 |
|
|
|
154 |
Shell shell = getShell (); |
155 |
shell.addListener (SWT.Deactivate, listener); |
156 |
|
131 |
createPopup(null, -1); |
157 |
createPopup(null, -1); |
|
|
158 |
setTabList(new Control[] {text}); |
132 |
initAccessible(); |
159 |
initAccessible(); |
133 |
} |
160 |
} |
134 |
static int checkStyle (int style) { |
161 |
static int checkStyle (int style) { |
Lines 282-289
Link Here
|
282 |
} |
309 |
} |
283 |
Shell shell = getShell (); |
310 |
Shell shell = getShell (); |
284 |
shell.removeListener (SWT.Deactivate, listener); |
311 |
shell.removeListener (SWT.Deactivate, listener); |
285 |
Display display = getDisplay (); |
|
|
286 |
display.removeFilter (SWT.FocusIn, filter); |
287 |
popup = null; |
312 |
popup = null; |
288 |
text = null; |
313 |
text = null; |
289 |
list = null; |
314 |
list = null; |
Lines 452-458
Link Here
|
452 |
if (x + width > displayRect.x + displayRect.width) x = displayRect.x + displayRect.width - listRect.width; |
477 |
if (x + width > displayRect.x + displayRect.width) x = displayRect.x + displayRect.width - listRect.width; |
453 |
popup.setBounds (x, y, width, height); |
478 |
popup.setBounds (x, y, width, height); |
454 |
popup.setVisible (true); |
479 |
popup.setVisible (true); |
455 |
list.setFocus (); |
|
|
456 |
} |
480 |
} |
457 |
/* |
481 |
/* |
458 |
* Return the lowercase of the first non-'&' character following |
482 |
* Return the lowercase of the first non-'&' character following |
Lines 687-698
Link Here
|
687 |
if (hasFocus) return; |
711 |
if (hasFocus) return; |
688 |
if (getEditable ()) text.selectAll (); |
712 |
if (getEditable ()) text.selectAll (); |
689 |
hasFocus = true; |
713 |
hasFocus = true; |
690 |
Shell shell = getShell (); |
|
|
691 |
shell.removeListener (SWT.Deactivate, listener); |
692 |
shell.addListener (SWT.Deactivate, listener); |
693 |
Display display = getDisplay (); |
694 |
display.removeFilter (SWT.FocusIn, filter); |
695 |
display.addFilter (SWT.FocusIn, filter); |
696 |
Event e = new Event (); |
714 |
Event e = new Event (); |
697 |
notifyListeners (SWT.FocusIn, e); |
715 |
notifyListeners (SWT.FocusIn, e); |
698 |
break; |
716 |
break; |
Lines 700-711
Link Here
|
700 |
case SWT.FocusOut: { |
718 |
case SWT.FocusOut: { |
701 |
if (!hasFocus) return; |
719 |
if (!hasFocus) return; |
702 |
Control focusControl = getDisplay ().getFocusControl (); |
720 |
Control focusControl = getDisplay ().getFocusControl (); |
703 |
if (focusControl == arrow || focusControl == list || focusControl == text) return; |
721 |
if (focusControl != list && focusControl != popup) dropDown(false); |
|
|
722 |
if (focusControl == arrow || focusControl == text || focusControl == list || focusControl == popup) return; |
704 |
hasFocus = false; |
723 |
hasFocus = false; |
705 |
Shell shell = getShell (); |
|
|
706 |
shell.removeListener(SWT.Deactivate, listener); |
707 |
Display display = getDisplay (); |
708 |
display.removeFilter (SWT.FocusIn, filter); |
709 |
Event e = new Event (); |
724 |
Event e = new Event (); |
710 |
notifyListeners (SWT.FocusOut, e); |
725 |
notifyListeners (SWT.FocusOut, e); |
711 |
break; |
726 |
break; |
Lines 1392-1404
Link Here
|
1392 |
} while (index < length); |
1407 |
} while (index < length); |
1393 |
return string; |
1408 |
return string; |
1394 |
} |
1409 |
} |
1395 |
void textEvent (Event event) { |
1410 |
void textEvent (final Event event) { |
1396 |
switch (event.type) { |
1411 |
switch (event.type) { |
1397 |
case SWT.FocusIn: { |
1412 |
case SWT.FocusIn: |
1398 |
handleFocus (SWT.FocusIn); |
1413 |
case SWT.FocusOut: { |
|
|
1414 |
getDisplay().asyncExec(new Runnable() { |
1415 |
public void run() { |
1416 |
handleFocus (event.type); |
1417 |
} |
1418 |
}); |
1419 |
|
1399 |
break; |
1420 |
break; |
1400 |
} |
1421 |
} |
1401 |
case SWT.KeyDown: { |
1422 |
case SWT.KeyDown: { |
|
|
1423 |
if (event.character == SWT.ESC) { |
1424 |
// Escape key cancels popup list |
1425 |
dropDown (false); |
1426 |
} |
1402 |
if (event.character == SWT.CR) { |
1427 |
if (event.character == SWT.CR) { |
1403 |
dropDown (false); |
1428 |
dropDown (false); |
1404 |
Event e = new Event (); |
1429 |
Event e = new Event (); |