Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 52d28c2

Browse files
author
zhourenjian
committed
Fixed bug that buttons with SWT.CHECK do not response on clicks
Fixed Combo layout bug
1 parent 79ed5bf commit 52d28c2

File tree

2 files changed

+46
-23
lines changed

2 files changed

+46
-23
lines changed

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

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,8 +1008,13 @@ public void setImage (Image image) {
10081008
if ((style & (SWT.RADIO | SWT.CHECK)) != 0) {
10091009
//// handleStyle.fontSize = this.image.height + "px";
10101010
// handleStyle.display = "block";
1011-
handleStyle.marginLeft = (CHECK_WIDTH + 3) + "px";
1012-
handleStyle.paddingLeft = (this.image.width + 3) + "px";
1011+
if (!OS.isIE) {
1012+
handleStyle.marginLeft = (CHECK_WIDTH + 3) + "px";
1013+
handleStyle.paddingLeft = (this.image.width + 3) + "px";
1014+
} else {
1015+
handleStyle.marginLeft = CHECK_WIDTH + "px";
1016+
//handleStyle.paddingLeft = (this.image.width + 3) + "px";
1017+
}
10131018
// handleStyle.paddingTop = this.image.height + "px";
10141019
//// handleStyle.lineHeight = this.image.width + "px";
10151020
//// btnText.appendChild(document.createTextNode(" "));
@@ -1031,6 +1036,9 @@ public void setImage (Image image) {
10311036
handleStyle.paddingLeft = (this.image.width + 1) + "px";
10321037
}
10331038
handleStyle.minHeight = this.image.height + "px";
1039+
if (OS.isIE && (style & (SWT.RADIO | SWT.CHECK | SWT.TOGGLE | SWT.PUSH)) != 0) {
1040+
handleStyle.height = this.image.height + "px";
1041+
}
10341042
if (OS.isIENeedPNGFix && image.url != null && image.url.toLowerCase().endsWith(".png") && handleStyle.filter != null) {
10351043
// Element imgBackground = document.createElement("DIV");
10361044
// imgBackground.style.position = "absolute";
@@ -1078,13 +1086,10 @@ public void setImage (Image image) {
10781086
this.image.draw(btnHandle);
10791087
}
10801088
if (OS.isIE && (style & (SWT.RADIO | SWT.CHECK)) != 0) {
1081-
boolean emptyText = (image != null || text.length() == 0);
1082-
if (OS.isIE70) {
1083-
btnHandle.parentNode.style.marginTop = emptyText ? "-2px" : "-3px";
1084-
} else if ((style & SWT.RADIO) != 0) {
1085-
btnHandle.parentNode.style.marginTop = emptyText ? "0" : "2px";
1089+
if (OS.isIE70 || OS.isIE80) {
1090+
btnHandle.parentNode.style.marginTop = "-3px";
10861091
} else {
1087-
btnHandle.parentNode.style.marginTop = emptyText ? "-1px" : "1px";
1092+
btnHandle.parentNode.style.marginTop = "1px";
10881093
}
10891094
}
10901095
}
@@ -1363,13 +1368,14 @@ public void run() {
13631368
if ((style & (SWT.CHECK | SWT.TOGGLE)) != 0) {
13641369
HTMLEvent e = (HTMLEvent) getEvent();
13651370
if ((style & SWT.CHECK) != 0) {
1366-
// Still buggy on check button with image
13671371
if (e.srcElement != btnHandle && e.target != btnHandle) {
13681372
setSelection (!getSelection ());
13691373
toReturn(false);
1370-
} else if (OS.isIE){
1374+
} else {
13711375
toReturn(true);
1372-
new HTMLEventWrapper(e).stopPropagation();
1376+
if (OS.isIE) {
1377+
new HTMLEventWrapper(e).stopPropagation();
1378+
}
13731379
}
13741380
} else {
13751381
setSelection (!getSelection ());
@@ -1400,10 +1406,8 @@ public void run() {
14001406
};
14011407
handle.onclick = handle.ondblclick = eventHandler;
14021408
if ((style & (SWT.RADIO | SWT.CHECK)) != 0) {
1403-
btnText.onclick = eventHandler;
1404-
}
1405-
if((style & SWT.CHECK) != 0){
1406-
1409+
handle.onclick = handle.ondblclick = null;
1410+
btnHandle.onclick = btnText.onclick = btnText.ondblclick = eventHandler;
14071411
}
14081412
handle.onkeydown = new RunnableCompatibility() {
14091413
public void run() {

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

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -753,11 +753,18 @@ void show(){
753753
selectInput.style.overflow = "auto";
754754
selectInput.style.height = "auto";
755755
}
756+
selectInput.style.left = "";
757+
selectInput.style.top = "";
758+
selectInput.style.width = "";
759+
selectInput.style.height = "";
760+
756761
selectInput.size = visibleCount;
757762
int w = Math.max(maxWidth, OS.getContainerWidth(handle));
763+
selectInput.style.display = "none";
758764
int h = OS.getContainerHeight(handle);
765+
selectInput.style.display = "";
759766
if (OS.isFirefox) {
760-
coordinate.x += 1;
767+
//coordinate.x += 1;
761768
//coordinate.y -= 1;
762769
h += 1;
763770
} else if (OS.isIE) {
@@ -769,21 +776,26 @@ void show(){
769776
window.currentTopZIndex = window.currentTopZIndex + 1;
770777
// related bug: http://groups.google.com/group/java2script/browse_thread/thread/8085561fcf953fc?hl=en
771778
selectInput.style.zIndex = window.currentTopZIndex + 4; //sgurin
772-
try {
773-
handle.removeChild(selectInput);
774-
document.body.appendChild(selectInput);
775-
} catch (Throwable e) {
776-
}
779+
777780
selectInput.className = "combo-select-box-visible" + (isSimple ? "" : " combo-select-box-notsimple");
778781
int height = OS.getContainerHeight(selectInput);
779782
Rectangle bounds = Popup.popupList(getMonitor().getClientArea(), new Rectangle(coordinate.x, coordinate.y, w, h), height);
780-
selectInput.style.left = bounds.x + "px";
783+
if (OS.isIE) {
784+
selectInput.style.left = (bounds.x + 1) + "px";
785+
} else {
786+
selectInput.style.left = bounds.x + "px";
787+
}
781788
selectInput.style.top = bounds.y + "px";
782789
if (bounds.height != height) {
783790
selectInput.style.overflow = "scroll";
784791
selectInput.style.height = bounds.height + "px";
785792
}
786793
selectInput.style.width = bounds.width +"px";
794+
try {
795+
handle.removeChild(selectInput);
796+
document.body.appendChild(selectInput);
797+
} catch (Throwable e) {
798+
}
787799
OS.SetFocus(selectInput); // selectInput.focus();
788800
}
789801

@@ -1720,6 +1732,7 @@ void setBounds (int x, int y, int width, int height, int flags) {
17201732
dropDownButton.style.width = buttonWidth + "px";
17211733
textInput.style.width = Math.max(0, width - buttonWidth - 5) + "px";
17221734

1735+
selectInput.style.width = width + "px";
17231736
} else {
17241737
// height = Math.min(height,
17251738
// OS.getContainerHeight(dropDownButton) + computeSelectHeight());
@@ -1730,8 +1743,14 @@ void setBounds (int x, int y, int width, int height, int flags) {
17301743
dropDownButton.style.display = "none";
17311744
textInput.style.width = width + "px";
17321745

1746+
selectInput.style.marginLeft = "-3px";
1747+
if (OS.isIE) {
1748+
selectInput.style.marginTop = "-2px";
1749+
selectInput.style.width = (width + 3) + "px";
1750+
} else {
1751+
selectInput.style.width = width + "px";
1752+
}
17331753
}
1734-
selectInput.style.width = width + "px";
17351754
}
17361755

17371756
/* (non-Javadoc)

0 commit comments

Comments
 (0)