seand
seand

Reputation: 478

How do I make a Composite selectable in Eclipse?

I have an editor which is comprised of a table and a set of selection-specific form fields below it, so that when I make a selection in the table, the fields below it will change. When the editor is sized too small, the fields container gets a scrollbar:

mockup

The problem is that when I make a selection in the table, I can't scroll the fields container down (with the mouse wheel) because the focus is still within the table. Currently I have to select one of the fields to be able to scroll its container or manually drag the scrollbar itself, but it's much easier to just click or hover anywhere in the target container to focus it for mouse wheel scrolling.

How can I make the composite body (in my case, a Form) selectable? Or even better, is there a way to control scrolling depending on where the mouse cursor is?

Upvotes: 0

Views: 207

Answers (1)

Gilbert Le Blanc
Gilbert Le Blanc

Reputation: 51445

If you want to control scrolling based on where the mouse cursor is located, you're going to have to write a combination org.eclipse.swt.events.MouseMoveListener and org.eclipse.swt.events.MouseWheelListener.

Component method setFocus() brings the component into keyboard focus.

I've not tried to do this. Be sure to handle the case where the user does not have a scroll wheel on their mouse.

Upvotes: 1

Related Questions