Skip to content

Commit 9ce2441

Browse files
author
zhourenjian
committed
Fixed bug that re-parenting children controls of Shell may get incorrect result.
Fixed bug that SWT.TOOL is not correctly layout. Fixed bug that Text's events is not correct. Fixed bug of Shell#bringToTop.
1 parent 526e22e commit 9ce2441

File tree

4 files changed

+10
-8
lines changed

4 files changed

+10
-8
lines changed

sources/net.sf.j2s.java.org.eclipse.swt/src/org/eclipse/swt/widgets/Control.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3412,7 +3412,7 @@ public boolean setParent (Composite parent) {
34123412
children[children.length + 1] = this;
34133413
Element topHandle = topHandle ();
34143414
topHandle.parentNode.removeChild(handle);
3415-
parent.topHandle().appendChild(handle);
3415+
parent.containerHandle().appendChild(handle);
34163416
// if (OS.SetParent (topHandle, parent.handle) == 0) return false;
34173417
// Element newHandle = this.handle.cloneNode(true);
34183418
// parent.handle.appendChild(this.handle.cloneNode(true));

sources/net.sf.j2s.java.org.eclipse.swt/src/org/eclipse/swt/widgets/Decorations.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -248,10 +248,10 @@ void bringToTop () {
248248
int count = children.length; //handle.childNodes.length;
249249
for (int i = 0; i < count; i++) {
250250
Control control = children[i]; //display.getControl (handle.childNodes[i]);
251-
if (control != null && control != this
252-
&& (control instanceof Shell) && control.isVisible()) {
251+
if (control != null && control != this && control.handle != null
252+
&& (control instanceof Shell)/* && control.isVisible()*/) {
253253
style = control.handle.style;
254-
if (style.zIndex != window.currentTopZIndex) {
254+
if (style != null && style.zIndex != window.currentTopZIndex) {
255255
style.zIndex = window.currentTopZIndex = ""
256256
+ (Integer.parseInt(window.currentTopZIndex) + 2);
257257
}
@@ -2304,7 +2304,7 @@ protected boolean SetWindowPos(Object hWnd, Object hWndInsertAfter, int X, int Y
23042304
} else {
23052305
int dw = 8;
23062306
int dh = 8;
2307-
if ((style & SWT.TOOL) != 0) {
2307+
if ((style & SWT.TOOL) != 0 || style == SWT.NONE) {
23082308
dw = 0;
23092309
dh = 0;
23102310
contentHandle.style.top = "0px";

sources/net.sf.j2s.java.org.eclipse.swt/src/org/eclipse/swt/widgets/Shell.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1372,12 +1372,12 @@ public void setVisible (boolean visible) {
13721372
if ((style & mask) != 0) {
13731373
if (visible) {
13741374
display.setModalShell (this);
1375-
/*
1376-
Control control = display._getFocusControl ();
1377-
if (control != null && !control.isActive ()) {
1375+
Control control = this; // display._getFocusControl ();
1376+
if (control != null && !control.j2sIsActive ()) {
13781377
bringToTop ();
13791378
if (isDisposed ()) return;
13801379
}
1380+
/*
13811381
int hwndShell = OS.GetActiveWindow ();
13821382
if (hwndShell == 0) {
13831383
if (parent != null) hwndShell = parent.handle;

sources/net.sf.j2s.java.org.eclipse.swt/src/org/eclipse/swt/widgets/Text.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,7 @@ public void run() {
322322
event.time = display.getLastEventTime ();
323323
}
324324
sendEvent(event);
325+
toReturn(!(!ev.doit || !event.doit));
325326
//sendEvent(SWT.KeyDown);
326327
}
327328
}
@@ -349,6 +350,7 @@ public void run() {
349350
event.time = display.getLastEventTime ();
350351
}
351352
sendEvent(event);
353+
toReturn(event.doit);
352354
}
353355
};
354356
}

0 commit comments

Comments
 (0)