Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » How to tell when scrollbar is at bottom?
How to tell when scrollbar is at bottom? [message #463424] Sat, 05 November 2005 16:06 Go to next message
Joshua Salit is currently offline Joshua SalitFriend
Messages: 15
Registered: July 2009
Junior Member
Hi,
I am trying to detect when a vertical scrollbar has been dragged to the
bottom for a StyledText, which is constantly growing in lines.

When I use the mouse to click on the area BELOW the scrollbar thumb, to
scroll the area, eventually the thumb gets to the bottom and
getSelection() + getThumb() == getMaximum becomes TRUE - this scenario
works great. However, when I left click on the thumb itself, and drag
it to the bottom, this never happens, so it seems I have no way of
detecting whether or not the thumb is at the bottom when the thumb
itself is being dragged.

Here's some code I've been using to debug -

final ScrollBar vBar = text.getVerticalBar();
vBar.addSelectionListener(new SelectionListener () {
public void widgetSelected(SelectionEvent e) {
switch(e.detail) {
case SWT.DRAG:
if((vBar.getSelection() + vBar.getThumb()) >= vBar.getMaximum())
System.out.println("at bottom (drag)!");
break;
case SWT.PAGE_DOWN:
if((vBar.getSelection() + vBar.getThumb()) >= vBar.getMaximum())
System.out.println("at bottom (PD)!");
break;
default:
System.out.println("e.detail: " + e.detail);
break;
}
}
public void widgetDefaultSelected(SelectionEvent e) {}
});

The "at bottom (drag)!" never hits, but the PAGE_DOWN one works as (I)
expected. I've also checked the other values (minimum, which for me has
always been 0, increment values, etc) of the scrollbar for things I
could use in the compare, without luck.

So...Am I missing something obvious, or might this be a bug?...

Thanks,
Josh
Re: How to tell when scrollbar is at bottom? [message #463479 is a reply to message #463424] Mon, 07 November 2005 22:17 Go to previous messageGo to next message
Joshua Salit is currently offline Joshua SalitFriend
Messages: 15
Registered: July 2009
Junior Member
Joshua Salit wrote:
> Hi,
> I am trying to detect when a vertical scrollbar has been dragged to the
> bottom for a StyledText, which is constantly growing in lines.
>
> When I use the mouse to click on the area BELOW the scrollbar thumb, to
> scroll the area, eventually the thumb gets to the bottom and
> getSelection() + getThumb() == getMaximum becomes TRUE - this scenario
> works great. However, when I left click on the thumb itself, and drag
> it to the bottom, this never happens, so it seems I have no way of
> detecting whether or not the thumb is at the bottom when the thumb
> itself is being dragged.
>
> Here's some code I've been using to debug -
>
> final ScrollBar vBar = text.getVerticalBar();
> vBar.addSelectionListener(new SelectionListener () {
> public void widgetSelected(SelectionEvent e) {
> switch(e.detail) {
> case SWT.DRAG:
> if((vBar.getSelection() + vBar.getThumb()) >= vBar.getMaximum())
> System.out.println("at bottom (drag)!");
> break;
> case SWT.PAGE_DOWN:
> if((vBar.getSelection() + vBar.getThumb()) >= vBar.getMaximum())
> System.out.println("at bottom (PD)!");
> break;
> default:
> System.out.println("e.detail: " + e.detail);
> break;
> }
> }
> public void widgetDefaultSelected(SelectionEvent e) {}
> });
>
> The "at bottom (drag)!" never hits, but the PAGE_DOWN one works as (I)
> expected. I've also checked the other values (minimum, which for me has
> always been 0, increment values, etc) of the scrollbar for things I
> could use in the compare, without luck.
>
> So...Am I missing something obvious, or might this be a bug?...
>
> Thanks,
> Josh

I understand the problem here has to do with the different behaviors of
the scrollbar depending on the user interaction - when a mouse click
registers on the scrollbar's thumb, the thumb doesn't update at all
(size-wise) until the mouse is released. For all other scrollbar
interaction, the thumb size continues to update.

However, I definitely think there should be a period of time, within a
SelectionEvent, in which I should be able to reliably determine using
the ScrollBar's APIs whether it is at the bottom or not..
Re: How to tell when scrollbar is at bottom? [message #463564 is a reply to message #463479] Tue, 08 November 2005 17:46 Go to previous message
Joshua Salit is currently offline Joshua SalitFriend
Messages: 15
Registered: July 2009
Junior Member
I've opened bug #115515 for this issue:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=115515
Previous Topic:Please vote for this feature request
Next Topic:SWT standelone application over network
Goto Forum:
  


Current Time: Thu Apr 25 15:12:10 GMT 2024

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

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

Back to the top