Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » max value
max value [message #466168] Wed, 04 January 2006 10:30 Go to next message
Eclipse UserFriend
Originally posted by: ingo.siebertNOSPAM.cas.de

Hi,

i use a table and i wanted to know, if a user drags the bar from the
vertical scrollbar to the maximum value.

The maximum value is never reached, so i can't do a check like

int scrollBarValue = scrollBar.getSelection();
int maxScrollBarValue = scrollBar.getMaximum();
if (scrollBarValue >= maxScrollBarValue) .... // fails anytime

I think that's the same in Swing and i hoped it doesn't exist in SWT.
Any idea how to solve this problem?
Thanks,

Ingo
Re: max value [message #466195 is a reply to message #466168] Wed, 04 January 2006 19:15 Go to previous messageGo to next message
Daniel Spiewak is currently offline Daniel SpiewakFriend
Messages: 263
Registered: July 2009
Senior Member
Possible hack:

Point p = ...; // an arbitrary point just up from the bottom of the table
TableItem lastItem = ...; // the last item added to the table

if (table.getItem(p).equals(lastItem))
    System.out.println("Scrolled to the bottom of the table");


You would have to set up a daemon thread which then put a call in to Display#asyncExec(Runnable) every few seconds (depending on how precise you need your timing to be) and pass a Runnable object which could call similar code to the above.

As you can probably see, this hack isn't a terribly good idea, but I honestly don't know enough about scrolling to give you another alternative. Anyone else want to bail me out? :-)
Re: max value [message #466252 is a reply to message #466168] Thu, 05 January 2006 14:24 Go to previous messageGo to next message
Veronika Irvine is currently offline Veronika IrvineFriend
Messages: 1272
Registered: July 2009
Senior Member
Composite c = new Composite(shell, SWT.V_SCROLL | SWT.H_SCROLL);
final ScrollBar bar = c.getVerticalBar();
bar.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
int scrollBarValue = bar.getSelection();
int maxScrollBarValue = bar.getMaximum();
int thumb = bar.getThumb();
if (scrollBarValue + thumb == maxScrollBarValue) {
System.out.println("Max reached");
}
}
});


"Ingo Siebert" <ingo.siebertNOSPAM@cas.de> wrote in message
news:dpg87i$4pq$1@utils.eclipse.org...
> Hi,
>
> i use a table and i wanted to know, if a user drags the bar from the
> vertical scrollbar to the maximum value.
>
> The maximum value is never reached, so i can't do a check like
>
> int scrollBarValue = scrollBar.getSelection();
> int maxScrollBarValue = scrollBar.getMaximum();
> if (scrollBarValue >= maxScrollBarValue) .... // fails anytime
>
> I think that's the same in Swing and i hoped it doesn't exist in SWT. Any
> idea how to solve this problem?
> Thanks,
>
> Ingo
Re: max value [message #466267 is a reply to message #466252] Thu, 05 January 2006 16:13 Go to previous message
Eclipse UserFriend
Originally posted by: ingo.siebertNOSPAM.cas.de

Thank you both.
It looks very promising and i will try i soon.

Ingo

Veronika Irvine schrieb:
> Composite c = new Composite(shell, SWT.V_SCROLL | SWT.H_SCROLL);
> final ScrollBar bar = c.getVerticalBar();
> bar.addSelectionListener(new SelectionAdapter() {
> public void widgetSelected(SelectionEvent e) {
> int scrollBarValue = bar.getSelection();
> int maxScrollBarValue = bar.getMaximum();
> int thumb = bar.getThumb();
> if (scrollBarValue + thumb == maxScrollBarValue) {
> System.out.println("Max reached");
> }
> }
> });
>
>
> "Ingo Siebert" <ingo.siebertNOSPAM@cas.de> wrote in message
> news:dpg87i$4pq$1@utils.eclipse.org...
>
>>Hi,
>>
>>i use a table and i wanted to know, if a user drags the bar from the
>>vertical scrollbar to the maximum value.
>>
>>The maximum value is never reached, so i can't do a check like
>>
>>int scrollBarValue = scrollBar.getSelection();
>>int maxScrollBarValue = scrollBar.getMaximum();
>>if (scrollBarValue >= maxScrollBarValue) .... // fails anytime
>>
>>I think that's the same in Swing and i hoped it doesn't exist in SWT. Any
>>idea how to solve this problem?
>>Thanks,
>>
>>Ingo
>
>
>
Previous Topic:Adding an Action to the Navigator View
Next Topic:adding content to a table if user scrolls down
Goto Forum:
  


Current Time: Wed Sep 18 13:16:38 GMT 2019

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

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

Back to the top