Custom composites & listener/event handling [message #1760198] |
Mon, 24 April 2017 09:48  |
Eclipse User |
|
|
|
We need to create a custom composite and are not sure how to register event listeners/handle events such as SWT.MouseEnter, SWT.MouseExit, SWT.Activate or SWT.Deactivate. Ideally we would only register listeners or handle events in such a way that events are only handled for the whole composite. Is that possible?
A simple example widget would be a class CustomComposite extending org.eclipse.swt.widgets.Composite containing only an inner label. The label however does not span the whole area of the composite.
+----CustomComposite----+
| |
| *----Label----* |
| | | |
| | Label text | |
| | | |
| *-------------* |
| |
+-----------------------+
What is the best practice for event handling or handling of listeners in a such a case?
SWT.MouseExit for example will be triggered if the mouse moves between the outter composite are and the inner label - which is not what we want because we are still with our composite.
* Is there some way to suppress the SWT.MouseExit event from being triggered in such a case
* Should we register a (or the same) handler also to the label and use inner variables (such as hover) to track the state of the compsite?
* Should we register a filter listener which seems costly and overkill in this case?
The only documentation we could find on this topic [1] which does not seem to handle such a case.
[1]: https://eclipse.org/articles/Article-Writing%20Your%20Own%20Widget/Writing%20Your%20Own%20Widget.htm
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04224 seconds