tags:

views:

146

answers:

1

I'm building a GWT app where I want to be able to detect when a user releases a scroll bar on one of my ScrollPanels.

My use case is that the horizontal scroll bar represents time. Since it's impossible to represent the full range of scrollable time I want to just represent a small window of time with the scroll bar. When the user moves and releases the scroll bar I want to do a smooth recentering where the new center is the release point.

I can work out how to do this by building a custom scroll bar widget, but I wanted to check if I was missing some way to do it using a "native" scroll bar first.

+1  A: 

You might be able to do it with a ScrollPanel and implementing your own ScrollHandler. Just use the addScrollHandler() method and you should be able to override whatever functionality you need.

However, I would suggest that you re-think your approach. What you seem to really want is a slider control for time, that kind of looks like a scroll bar. You should check out the Composite class and the Widget Gallery to see if there is some combination of Widgets that would suit what you need more. Failing that, I'd also look at SmartGWT. They have a very extensive library of GUI Widgets available, and you may find something you can use already there.

adam
Thanks, "Just use the addScrollHandler() method and you should be able to override whatever functionality you need." I did look at this part of the API. If there is a way to detect scrollbar release it isn't clear to me. (Edited for formatting)
Keith
In the onScroll() method of a ScrollHandler you get a ScrollEvent as a parameter. It has a method called getAssociatedType(). The associated DomEvent has a method called getName(). Try that. However, I still think you should re-think your approach to the problem.
adam
I coded up an example and I've found that no ScrollEvent is fired on release (events are only fired when the scroll bar moves... at least this is true with Safari). Regarding re-thinking the approach, I'm in the very early stages of design and development and plan to re-evaluate all of my UI decisions. In any case it's worth knowing if this is possible or not. At this point I'm leaning towards not possible. Thanks again
Keith