world.SetScroll

MUSHclient script function (Method) — introduced in version 4.60

Sets the scroll bar position, and hides or shows it

Prototype

long SetScroll(long Position, BOOL Visible);

Data type meanings

Description

This lets you do two things:

* Hide the existing scroll bar if desired
* Set the "scroll position" in the output window

The first feature (hiding the scroll bar) lets you, well, hide it, so that you can draw your own wherever you want (eg. with a themed miniwindow somewhere near where the text appears).

The second feature lets your code scroll the text around (so you can still use the existing output buffer) in response to the player clicking and dragging on "your" thumb, or arrows.

A position of -1 means "the end of the window" (which is the number of lines multiplied by the size of the font, less the size of the output window).

A position of -2 means "no change".

You can use GetInfo (296) to find the current scroll-bar position (and thus add or subtract from it, to scroll up or down small amounts (like a line or a page).

You can use GetInfo (120) to find if the scroll-bar is currently hidden or not.

The existing code adds the font height (GetInfo (212)) to the current scroll position to scroll downwards a line, and subtracts it to scroll up a line.

To scroll up or down pages you need to find the size of the output window text rectangle, and add or subtract that.

Lua example

SetScroll (0, false)  -- hide scroll bar, go to top of window
SetScroll (-1, false) -- hide scroll bar, go to end of window

SetScroll (-2, false) -- hide scroll bar, do not change position
SetScroll (-2, true)  -- show scroll bar, do not change position

Lua notes

The Visible flag is optional and defaults to true.

Return value

eOK - success

Return code meanings

See also

FunctionDescription
GetInfoGets information about the current world