Reputation: 1314
I would like to forward all events from one widget to another in SWT. Is it possible to do this?
For the record:
I have a checkbox widget set against a dark background. On Windows, it is impossible to actually set the color for a button label, Windows uses black, making my checkbox illegible. Hence my solution was to create a checkbox with no label, and put a standard SWT label next to it. This works great until I try to click on the label. The expected behavior is that a click/hover on the label is the same as a click/hover on the checkbox.
Upvotes: 2
Views: 192
Reputation: 4617
I'd recommend you to add a paintListener
to your checkbox and on its paintControl
method redraw the text with the color you want on the same position of the original text.
This way you won't have an extra widget to deal with.
EDIT:
As you said the PaintListener
is not an option, then I'd suggest you to add to the label listeners to all events you want to forward to the checkbox.
On the checkbox, add the same listeners (not the same instances, the same types).
Finally, on the listeners added to the label, just do
yourCheckBox.notifyListeners( eventType, event );
Upvotes: 1
Reputation: 9162
Can't you just create one instance of the listener and add it to both widgets?
Upvotes: 0