| Summary: | Checkbox with null text will display a empty rectangle | ||
|---|---|---|---|
| Product: | [Eclipse Project] Platform | Reporter: | DartPeng <blackfrezee> |
| Component: | SWT | Assignee: | Alexander Kurtakov <akurtakov> |
| Status: | RESOLVED FIXED | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | akurtakov, astevenson, cgold, Christoph.Krueger, mark, remy.suen, vrubezhny, vyemialyanchyk |
| Version: | 3.5.2 | ||
| Target Milestone: | 4.4 M6 | ||
| Hardware: | PC | ||
| OS: | Linux | ||
| Whiteboard: | |||
| Attachments: | |||
|
Description
DartPeng
Can you attach a sample code? Created attachment 170308 [details]
unwanted widget
(In reply to comment #1) > Can you attach a sample code? oh , you are so quickly. The codes is very simple , just create two controls in the same parent container: toolkit.createLabel(parent, "Label :") .setForeground(toolkit.getColors().getColor(IFormColors.TITLE)); gd = new GridData(SWT.FILL, SWT.NONE, true, false); checkbox = toolkit.createButton(parent, null, SWT.CHECK); checkbox.setLayoutData(gd); > oh , you are so quickly. You haven't seen Remy in action. He can mark a bug as duplicate before even its submitted :-) > The codes is very simple , just create two controls in the same parent > container: > > toolkit.createLabel(parent, "Label :") > .setForeground(toolkit.getColors().getColor(IFormColors.TITLE)); > > gd = new GridData(SWT.FILL, SWT.NONE, true, false); > > checkbox = toolkit.createButton(parent, null, SWT.CHECK); > checkbox.setLayoutData(gd); I can't reproduce this on 3.5.2 Could be a linux specific bug. Assigning to UA for investigation. Created attachment 170319 [details]
Mac screenshot ...
Same code tried in Mac
Created attachment 170400 [details]
Screenshot from Linux using Chris's sample code
I tried this on Linux, the snippet did not give all the context so I extrapolated it a bit by creating a plug-in with a view from the the project wizard and replacing createPartControl with the code below. This tests with and without the FormToolkit. In either case I can see that a label is created for the checkbox, it does not have a border so it does not show until you select the checkbox at which time the label gets a selection box.
I'm not seeing the same type of control that you are, I was on RHEL5, it looks as though you are on Ububtu. In any case I think that what you are trying to do is not going to work for a number of reasons. Tabbing is not going to work correctly becuse the label attached to the checkbox is empty, this will not work for users with screenreaders.
public void createPartControl(Composite parent) {
Composite inner = new Composite(parent, SWT.NULL);
inner.setLayout(new GridLayout(2, false));
Button checkbox1, checkbox2;
Label label1 = new Label(inner, SWT.NULL);
checkbox1 = new Button(inner, SWT.CHECK);
label1.setText("Label1 :");
GridData gd1 = new GridData(SWT.FILL, SWT.TOP, true, false);
checkbox1.setLayoutData(gd1);
FormToolkit toolkit = new FormToolkit(parent.getDisplay());
GridData gd2 = new GridData(SWT.FILL, SWT.TOP, true, false);
toolkit.createLabel(inner, "Label2 :").setForeground(toolkit.getColors().getColor(IFormColors.TITLE));
checkbox2 = toolkit.createButton(inner, null, SWT.CHECK);
checkbox2.setLayoutData(gd2);
}
Returning to SWT team - I don't think the FormToolkit is the cause of the problem, I recommend that this either be treated as an enhancement request to add a flag to allow the label to appear before the checkbox or closed as invalid since the code is not using a checkbox as designed. I have the same issue I think. I'm using Ubuntu Linux and the following code:
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new GridLayout(1, false));
Button button = new Button(shell, SWT.CHECK);
button.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
shell.open();
while (! shell.isDisposed()) {
if (! display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
}
I don't get the whole rectangle to the right, just the first few pixels - screen shot to be attached in a minute. It only shows when the window it is in is the active window. It seems to disappear at other times.
Created attachment 187549 [details]
Screen shot from sample code I just posted (Linux)
(In reply to comment #8) > I have the same issue I think. I'm using Ubuntu Linux and the following code: And the version.txt from within swt.jar says version 3.655 We see the same annoying effect using SWT under AIX. I pushed a fix for the issue here: https://git.eclipse.org/r/19165 SWT/GTK org.eclipse.swt.widgets.Button class is changed to control the visibility of box, label and image widgets due ton hide all the three widgets in case of empty label and image at the same time. This contribution complies with http://www.eclipse.org/legal/CoO.php Created attachment 237881 [details]
The image of fixed checkbox with empty label
Here's how my fixed check box should look in case of empty label and null-image.
I see the problem but even with your patch it doesn't fix the problem for me (on gtk2). What is more weird is that with gtk3 with or without your patch I don't see the problem. It's not weird that all may work fine in GTK3, but I cannot argue here, 'cause i'm a victim of bug #421127 at the moment (My eclipse's views are all empty when I'm starting my eclipse by default). Regarding the use of GTK2, I need a bit of time to investigate the non-working fix (I've moved on f20 currently, while my last tests on the issue where done on f19 where GTK2 was the default... At least I thought it was default there). Yes, Andrey, you're correct. My previous patch set was working only if you're putting the lines of code like:
button.setText("");
or
button.setImage(null);
right after the button is created.
When there are no such calls, the buggy effect stays the same as described above.
I've created a Patch Set 6 with the fixed Button.showWidget() method. So, you can test it with the code snipped from Comment #8 (https://bugs.eclipse.org/bugs/show_bug.cgi?id=314815#c8).
Thanks for your review.
Created attachment 239496 [details]
Luna, GTK3 and the Checkbox with empty label bug
Alexander! (Shame on me! I've called you as Andrey - Sorry for that)
The image attached shows this bug on my Luna and GTK3. It's reproduced, as you can see. My patch set 6 solves the issue also on GTK3... At least in my environment.
(In reply to Victor Rubezhny from comment #17) > Created attachment 239496 [details] > Luna, GTK3 and the Checkbox with empty label bug > > Alexander! (Shame on me! I've called you as Andrey - Sorry for that) > > The image attached shows this bug on my Luna and GTK3. It's reproduced, as > you can see. My patch set 6 solves the issue also on GTK3... At least in my > environment. Hi Victor, Thanks for the patch. Works good for me and I pushed it to master http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=b2170202dd439d59048cdf10292188058b2ca5b9 . Keep them coming :). Small additional fix unbreaking images showing for push buttons. http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=d18da1a6a32433411174b2025f6381c1db547bb7 (In reply to Alexander Kurtakov from comment #19) > Small additional fix unbreaking images showing for push buttons. > http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/ > ?id=d18da1a6a32433411174b2025f6381c1db547bb7 Thanks for this, Alexander! |