tags:

views:

119

answers:

1

I have a ScrolledComposite which is a bit like an spreadsheet. It works mostly without problems, but I sometimes have a large field that fills almost an entire row (the rightmost part).

When focus is on this field, and setShowFocusedControl(true) has been called, swt insists on showing the rightmost part of the field, which has the same effect as scrolling all the way to the right on a big spreadsheet - it is very annoying for the user, as the field rarely has very much text in it.

So the strategy chosen in the code is to setShowFocusedControl on and off all the time, which is very bug-prone.

Can someone suggest a better strategy? Can I make swt show the leftmost part of the focussed field?

A: 

you can use setOrigin(Point) or setOrigin(int, int) on the ScrolledComposite to set the origin of the scrolled content at the top left.

darko.topolsek
Thanks for the answer - that's actually what I have done, and it seems to work - but it still means that I have to do it manually each time. Any code that can shift focus on to one of these lines has to include this hack.So I am still open for better solutions - although I am not convinced that there is one. I'll give you best answer if nothing better comes before monday.
danskal