Saturday, June 27, 2009

Adding Scroll bar into S60

I was having a problem to show the content inside Nokia X5800 as the content was huge. Two solutions for this:
  1. Redesign the content.
  2. Add scroll bar into it.
Anyhow, I am force to use the 2nd option due to the urge from requirement. Unfortunately the srcroll bar component was not inside the eSWT library. Thus a message was send out in the Nokia forum to see how this can be done.

In the mean time, I did some Google search looking for alternate solution. I got one at last, which is, I have to manually handle everything from drawing to event handling. This is the worst solution if there are no more other choices. I continue my research on scroll bar while waiting reply from Nokia forum.

The first post was reply. And he mention that I have to draw the scroll bar on canvas and receive the "down" key event in keyPress(), and then update everything in the content. Almost similar to the one I found in Google.

Base on this website, eSWT was already handled the scroll bar automatically, but the problem was that when I click and drag the scroll bar, it doesn't work. Until my friend told me that I was using the wrong emulator (I was using 3rd edition FP2 during that time) and he suggest me to use N97 emulator. Then only I notice that this is the only emulator which support touch screen.

From the answer I get from Nokia Forum, I got good news and bad news.

Here is good news:

eSWT Scrollbars on Scrollable provide low level access to scroll events so that the applications can implement their own scrolling logic. You can register for those events using the Scrollable.getHorizontalBar() or Scrollable.getVerticalBar() to get a handle to the scrollbar instance and adding a SelectionListener.

Also there is a custom utility class in Eclipse that provides automated Scrolling for Composites Called ScrolledComposite. You can fetch it from Eclipse Project.

Posted by gorkem.ercan

And here was the bad news:

There is also an ongoing discussion whether ScrolledComposite or an equivalent should become part of the eSWT here. You can actually comment/follow on the progress of that as well.

Posted by gorkem.ercan

Anyhow, my friend was able to make a custom scroll on that phone. Although it is not working perfect, but it still can satisfied the project requirement.

No comments: