How to tell when scrollbar is at bottom? [message #463424] |
Sat, 05 November 2005 16:06 |
Joshua Salit 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 |
Joshua Salit 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..
|
|
|
|
Powered by
FUDForum. Page generated in 0.03413 seconds