Building a scrollbar...

2 posts / 0 new
Last post
uditmahajan
uditmahajan's picture
Offline
Joined: 13 Dec 2009
Posts:
Building a scrollbar...

I want to create a generic screen which will display text as well as images in a way that i can scroll them..
currently if i use label or listbox, it doesn't show any sort of scrollbar, though it does allow to add text/images but it is not elegant. i am not asking for a ready made control.. even an idea will do, i'l write it myself. i am just not able to get the idea how to start such a control... Crying

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Sam Pickard
rival's picture
Offline
Mobile Archmage
Joined: 19 Mar 2009
Posts:

There are a couple of ways you can do it. Firstly, you can take the ListBox code from https://github.com/MoSync/MoSync and create a new Widget based on that. You know the size of the complete list box (the sum of listbox->getChildren()[n].size()), the amount you've got visible on screen, and the yOffset of the listbox so you can show how far down the screen it is. You can then draw a scroll box on the side.

Secondly, you can create a new widget which contains a listbox and set aside some space for the scrollbar. You can still tell the total amount of space required by the listbox, and the amount you've got on screen, but you can't tell by how much the listbox has already scrolled. Either you need to do it the first way, or create a new listbox class from the source and just expose the yOffset and do it the second way.

There is a tutorial coming soon on creating new widgets which may help as well.

Let me know if you've got any more questions about how to do this.