Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Custom composites & listener/event handling(Event handling when moving between different elements of a composite)
Custom composites & listener/event handling [message #1760198] Mon, 24 April 2017 13:48 Go to next message
Lothar Lattermann is currently offline Lothar LattermannFriend
Messages: 26
Registered: July 2016
Junior Member
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
Re: Custom composites & listener/event handling [message #1760419 is a reply to message #1760198] Thu, 27 April 2017 03:09 Go to previous messageGo to next message
Brian de Alwis is currently offline Brian de AlwisFriend
Messages: 694
Registered: January 2012
Senior Member

You'll need to handle this yourself. Basically your MouseExit will need to check if the widget is still within your Composite via Control#getParent().

Eclipse Platform committer. Ask me about Eclipse support, training, and consulting.
Re: Custom composites & listener/event handling [message #1760468 is a reply to message #1760419] Thu, 27 April 2017 14:33 Go to previous message
Lothar Lattermann is currently offline Lothar LattermannFriend
Messages: 26
Registered: July 2016
Junior Member
Brian de Alwis wrote on Thu, 27 April 2017 03:09
You'll need to handle this yourself. Basically your MouseExit will need to check if the widget is still within your Composite via Control#getParent().


Thank you for taking the time to clarifying this!
Previous Topic:MenuItem tooltip timer exception
Next Topic:SWT Browser DND on MacOSX
Goto Forum:
  


Current Time: Mon Dec 18 07:21:52 GMT 2017

Powered by FUDForum. Page generated in 0.01641 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software