Page 1 of 1

How to Make Content Box with Scroll Bar (Like a Web Browser)

PostPosted: Tue Jul 24, 2007 10:59 pm
by dan208
I want to make an application with this program rather than a game, because it looks like it would work great to make cross platform applications. What I am wondering is, is it possible to make a browser box with a side-scroll bar(I'm not talking a side scroller game, here :) j/k). I hope I explained it well enough, but I will jabber more to hopefully convey what I mean: basically like on a web browser on the side is the scroll bar to sift through the web page from top to bottom. Can this be done? Can this be automatically done or is this something that would need to be programmed? Thanks in advance for your help.

PostPosted: Wed Jul 25, 2007 12:57 am
by DilloDude
You would have to set up script to do this. I'd use three actors: the up arrow button, the down arrow button, and the slider in the middle. On a mouse button down event with the arrow buttons, change the slider's yscreen position by 1 (either up or down, accordingly). Add a slider mouse button down event that sets a variable, grabbed, to 1. A mouse button up event should set grabbed to 0. Add a draw actor event on slider
Code: Select all
double slidepos;
int slideamount;
if (grabbed)
{
    if (ymouse > maxy)//replace maxy with slider's position at the bottom of the bar
    {
        yscreen = maxy;
    }
    else if (ymouse < miny)//replace miny with slider's position at top of screen
    {
        yscreen = miny;
    }
    else
    {
        yscreen = ymouse;
    }
}
//that should let you drag slider up and down the bar
//next you need script to position the window. you can either move view or the window background.

//if the window size remains constant, you can precalculate some of these values, otherwise, you'll need to put them in script.

slidepos = (yscreen - miny) / (maxy - miny);
slideamount = window.height - view.height;
window.yscreen = (slidepos * slideamount) + (window.height * .5 - view.height * .5);

I think this should work, just double-check the code at the end. If you have further problems I may be able to make a demo in a few days.

PostPosted: Wed Jul 25, 2007 3:52 am
by dan208
Thanks so much for your reply! That's just what I needed to know. I really appreciate your help.

PostPosted: Thu Jul 26, 2007 4:51 pm
by DarkParadox
i could really use this for one of my games
but i dont get it more details or an easier
way please.