SWT ControlDecoration 去 behing 相邻控件

SWT ControlDecoration goes behing adjacent control

如您在所附屏幕截图中所见,我有两个相邻的 SWT 按钮,它们可以显示 装饰ControlDecoration 对象)。

当我激活装饰时,它被相邻的按钮部分隐藏:有什么方法可以保持布局间距紧凑并在图层堆栈的顶部显示装饰?

ControlDecoration 的 JavaDoc 说:

ControlDecoration renders the image adjacent to the specified (already created) control, with no guarantee that it won't be clipped or otherwise obscured or overlapped by adjacent controls, including another ControlDecoration placed in the same location. Clients should ensure that there is adequate space adjacent to the control to show the decoration properly.

所以,不,没有办法让这个节目在控件之上。

如果您的 Button 正在显示图像,您可以使用标签装饰 (class LabelDecorator) 创建合成图像,该图像是按钮图像和右上角的小图像的结果。