This Question is Assumed Answered

1 "correct" answer available (5 pts) 15 "helpful" answers available (3 pts)
3 Replies Last post: Aug 6, 2008 9:01 PM by carl

a question of ScrollBox

Aug 6, 2008 6:55 PM

Click to view Poseidon.UD's profile Level 2 Poseidon.UD 37 posts since
Jul 3, 2008

Now, i use ScrollBox 's {scroll-to-object object1}

if there are many object in ScrollBox,and the object1 is not at bottom part, the object1 can scroll the object1 to Top.

but if the object1 at bottom part,i want to scroll the object1 to Top,

use VB or VC,the function can implement,Use Curl,how to do?

underside, add a HBox ? this isn't good way.


Click to view fukuta's profile BlackBelt fukuta 105 posts since
Oct 17, 2007
1. Re: a question of ScrollBox Aug 6, 2008 7:33 PM
This example meets your requirement?

{curl 6.0 applet}

{value
    def objects = {{Array-of Graphic}}
    def vb = {spaced-vbox}
    {for i = 0 to 9 do
        def f = {Frame width = 2cm, height = 1cm, background = "yellow", i}
        {objects.append f}
        {vb.add f}
    }
    def scroll-box = {ScrollBox
                         width = 3cm,
                         height = 5cm,
                         expanded-vscroll-bounds? = true,
                         vb
                     }
    {spaced-vbox
        {CommandButton
            label = "scroll to bottom",
            {on Action do
                {scroll-box.scroll-to-object {objects.get objects.size - 1}}
            }
        },
        scroll-box
    }
}


In this example, expanded-vscroll-bounds? that is ScrollBox's option is set to true.
Click to view carl's profile Curl carl 74 posts since
Oct 17, 2007
2. Re: a question of ScrollBox Aug 6, 2008 7:51 PM
If I am reading your question correctly, you are asking how to scroll the bottommost content of a ScrollBox its top?

If so, then you can't do that without expanding the scrollable area somewhat. Normally there's just enough play in a ScrollBox to allow the maximum edges of the child and the ScrollBox to line up. You can set the local option expanded-vscroll-bounds? = true to have the ScrollBox put in enough play to allow, in your example, the bottommost element to be just brought offscreen over the top of the ScrollBox. (There's a matching option for the horizontal direction, expanded-hscroll-bounds?.)
Click to view carl's profile Curl carl 74 posts since
Oct 17, 2007
3. Re: a question of ScrollBox Aug 6, 2008 9:01 PM
in response to: carl
Ha, I see that I was actually second to answer your question. Right, as the above poster already mentioned.