ID:1849786
 
(See the best response by Lummox JR.)
Code:


Problem description:

Hi I'm trying to create a scrollable message viewer, where messages are dynamically added and you can click on a message, to view it something like the image.

Now I'm thinking of using a Button for that purpose and these buttons to be able to be scrolled, but how can I implement that efficiently.

I've thought of creating a slider and when its values change accordingly output the appropriate messages. Any better solutions??


For something simple, you can use a grid control. You can pretty much treat it as a list and it already has an actual working scroll bar.

Any more complicated/fancy and you might as well use a browser control.

Basically, I'm recommending that you don't try to make your own scroll bar, if you want a scroll bar.
Ok so how can I add objects to the grid?
And is there any resources about how grid/browser works??

About browser I'll have to create an html page to be used as url and interact with JavaScript to enable byond procs right??
Also if I proceed with the grid option can I customize the scroll-bar??

And if I proceed with browser option is there a web browser installed restriction, or any browser works?? and since there is no data input can it be exploited??

And finally which is more efficient a browser or a grid control??
In response to Victorqr
Victorqr wrote:
Ok so how can I add objects to the grid?
And is there any resources about how grid/browser works??

The easiest way to output to a grid is to send an object like so:

player << output(myobj, "grid:[col],[row]")

And you can set the grid.cells value via winset() to trim off any excess cells. Of course "grid" should just be whatever your grid control is actually named, be it "inventory" or "equipment" or whatever.

The output can be text; it doesn't have to be an obj. However the grid control in DS does not support mixed styles like full HTML. If you want full HTML, you'll have to either use a browser control, or use the webclient and just do without mixed styles in DS.
Nice, so it works like an html table. Can I use align left- right-center or change the cell size??
Also is there an on-click event for when clicking an object displayed in the grid??
Best response
Alignment options are supported, although I'm not actually sure there's currently any way to do it for atoms. (Something to think about as an enhancement, I guess.) Atoms clicked in the grid will call Click(); it works just like having an atom in the statpanel in that regard.

Also regarding cell size, the grid is currently auto-sizing only. There are no width/height-fixing options, although I'm not averse to adding them.
I tried to output an obj in the screen and overided the Click() proc to print a message but when I clicked nothing happened
ok my mistake I found out whats going on with click Thanks for the help :)

Ok all done now I need to style it so how can I use CSS with a grid??
As I said, styling options will be very limited.

You can output HTML text there if you're not going to use an atom, but it will be all one style. Grids will let you use a link (the whole cell will be a link), which would go to client/Topic() instead of acting like clicking an obj.

In the grid control there's a style parameter (not currently supported on the webclient, just FYI) you can use to specify default styles.
ok so I tried margin-left:50px (in style) but nothing happened
also when I output an object the cell is too large and does not fit the object
Ok I figured out the Style, but the autosizing of cells is messing with my grid I mean I have huge cells that contain 40x50 atoms, is there a way to set the cell height
Again, the grid has no explicit sizing options for cells at this time. It's a possible future feature.