Community
Participate
Working Groups
Step to reproduce: 1. Create a ColorSelector and a button in a dialog. 2. Set the image of the ColorSelector to null and the one of the button to an image. 3. Open this dialog twice. You can see the image of the button is shown on the ColorSelector when it opens for the second time. If I open the dialog only once or reverse the creation order of these two controls, this appearance doesn't exist. But if I create a image before create the dialog, this appearance occurs even the first time.
Created attachment 39872 [details] The source code of the dialog
Created attachment 39873 [details] The source code of the dialog luncher for the first case
Created attachment 39874 [details] The source code of the dialog luncher of the first case
Comment on attachment 39873 [details] The source code of the dialog luncher for the first case Duplicated submitting
Created attachment 39875 [details] The source code of the dialog luncher of the second case
This appearace exsits only in 3.2RC1.
*** Bug 175958 has been marked as a duplicate of this bug. ***
(In reply to comment #6) > This appearace exsits only in 3.2RC1. > Do you mean that it's no longer a problem (i.e. is it still an issue in the actual 3.2 release) ?
At that stage when the bug reported, it's in 3.2RC1. Looks it is still a problem by reporting of item 175958. Thanks (In reply to comment #8) > (In reply to comment #6) > > This appearace exsits only in 3.2RC1. > > > > Do you mean that it's no longer a problem (i.e. is it still an issue in the > actual 3.2 release) ? >
*** Bug 178448 has been marked as a duplicate of this bug. ***
*** Bug 185608 has been marked as a duplicate of this bug. ***
*** Bug 190226 has been marked as a duplicate of this bug. ***
ColorSelector is designed to simply draw a color rectangle in a GC and is not designed to support text. Text is actually quite hard to show because you need to make sure the color of the text is readable with the color of the background which constantly changes. We currently are not planning to add support for this but should you wish to add a patch that adds this support we would be happy to review it.
I'm reopening this. Actually this bug is not requesting for supporting text drawing in ColorSelector (the title may misleading), we just want it to support the 'null' value setting, e.g. ColorSelector.setColorValue(null). When the value is null, we expect the button has the same visual effect as it is first created, e.g. just button background, no black rectangle line. Currently when you set null value to ColorSelector, exception will thrown out. I think this just needs a few lines of change in method updateColorImage(). Our current workaround is to use ColorSelector.getButtion().setImage(null), this causes the problem, while this could also be an SWT or Windows bug. Of course we can do something elase to work around this, like copy and modify the whole ColorSelector source, but it's better if this can be fixed internally.
This bug is open since 2006, and the fix is very simple. --- ColorSelector.java 2012-08-24 15:21:05.677278682 -0400 +++ ColorSelector.java 2012-08-24 15:24:17.781276846 -0400 @@ -198,8 +198,12 @@ if (fColor != null) { fColor.dispose(); } - fColor = new Color(display, fColorValue); - gc.setBackground(fColor); + if(fColorValue!=null) { + fColor = new Color(display, fColorValue); + gc.setBackground(fColor); + } else { + gc.setBackground(fButton.getBackground()); + } gc.fillRectangle(1, 3, fExtent.x - 2, fExtent.y - 5); gc.dispose(); fButton.setImage(fImage);