Determining if scrollbars are visible [message #517352] |
Fri, 26 February 2010 22:53  |
Eclipse User |
|
|
|
Hi,
I just stumbled upon a bug in (I guess) JFace where a table gets an unneccessary scroll
bar: https://bugs.eclipse.org/bugs/show_bug.cgi?id=304128
I wanted to determine in my unit test if scroll bars are shown for a table. According to
the API docs I thought this would work:
boolean hscroll = table.getHorizontalBar() != null
&& table.getHorizontalBar().isVisible()
Unfortunately this doesn't work (at least not on Cocoa), it always evaluates to true, even
when no horizontal scrollbar is visible. Is this supposed to work or is there a supported
way to get this information?
Greetings,
Ralf
--
http://www.ralfebert.de/blog/eclipsercp/
|
|
|
Re: Determining if scrollbars are visible [message #517663 is a reply to message #517352] |
Mon, 01 March 2010 06:14  |
Eclipse User |
|
|
|
Hi,
I think the approach you've tried should work, so you're probably seeing a
bug in swt's Cocoa port.
An alternative approach would be to infer whether the scrollbar would be
visible or not based on the Table's desired and actual heights. This can be
computed with something like:
int desiredHeight = table.getHeaderHeight() + (table.getItemCount() *
table.getItemHeight());
int clientHeight = table.getClientArea().height;
return clientHeight <= desiredHeight;
Grant
"Ralf Ebert" <info@ralfebert.de> wrote in message
news:hma50e$m7b$1@build.eclipse.org...
> Hi,
>
> I just stumbled upon a bug in (I guess) JFace where a table gets an
unneccessary scroll
> bar: https://bugs.eclipse.org/bugs/show_bug.cgi?id=304128
>
> I wanted to determine in my unit test if scroll bars are shown for a
table. According to
> the API docs I thought this would work:
>
> boolean hscroll = table.getHorizontalBar() != null
> && table.getHorizontalBar().isVisible()
>
> Unfortunately this doesn't work (at least not on Cocoa), it always
evaluates to true, even
> when no horizontal scrollbar is visible. Is this supposed to work or is
there a supported
> way to get this information?
>
> Greetings,
>
> Ralf
>
>
> --
> http://www.ralfebert.de/blog/eclipsercp/
|
|
|
Powered by
FUDForum. Page generated in 0.05273 seconds