# ScrollController

{% hint style="info" %}
Class (inherits from [ContainerControl](https://documentation.xojo.com/api/deprecated/containercontrol.html))
{% endhint %}

## Methods

| [AddView](/add-ons/stackview/version-2/details/scrollcontroller.md#addview-view-as-viewcontroller-index-as-integer-1) | [Expand](/add-ons/stackview/version-2/details/scrollcontroller.md#expand-value-as-boolean)                                                                                          |
| --------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [GetViews](/add-ons/stackview/version-2/details/scrollcontroller.md#getviews-as-viewcontroller)                       | [Init](/add-ons/stackview/version-2/details/scrollcontroller.md#init-stackview-as-stackcontroller-scrollbar-as-scrollbar-animated-as-boolean-true-usensscrollview-as-boolean-false) |
| [RemoveView](/add-ons/stackview/version-2/details/scrollcontroller.md#removeview-index-as-integer-1)                  |                                                                                                                                                                                     |

### AddView

Adds a View (dynamically at the Runtime) to the StackView.

**Parameters**

<table data-header-hidden><thead><tr><th width="150">Name</th><th width="150">Datatype</th><th width="414.8">Description</th></tr></thead><tbody><tr><td>Name</td><td></td><td>Description</td></tr><tr><td><em>view</em></td><td><a href="/pages/-LMJNEDBTqxFeeknur5v">ViewController</a></td><td>Pointer to the View which should be added to the StackView.</td></tr><tr><td><em>index</em></td><td><a href="https://documentation.xojo.com/api/data_types/integer.html">Integer</a> = -1</td><td>Position to add the View into the StackView.</td></tr></tbody></table>

### Expand

Expand or collapse the StackController.

**Parameters**

<table data-header-hidden><thead><tr><th width="150">Name</th><th width="150">Datatype</th><th width="450.5207756232687">Description</th></tr></thead><tbody><tr><td>Name</td><td></td><td>Description</td></tr><tr><td><em>value</em></td><td><a href="https://documentation.xojo.com/api/data_types/boolean.html">Boolean</a></td><td>A Boolean specifiying the state of the <a href="/pages/-LMJNJAHEjHD4ToJEIAU">StackController</a>.</td></tr></tbody></table>

**Sample Code**

PushButton1 `Action`-Event:

```xojo
MyScrollController1.Expand(True)
```

### GetViews As [ViewController()](/add-ons/stackview/version-2/details/viewcontroller.md)

Returns an Array of the StackViews Views.

### Init

Creates a new ScrollContainer starting with the given Parameters. `UseNSScrollView` is optional.

**Parameters**

<table data-header-hidden><thead><tr><th width="192.91780821917806">Name</th><th width="152.89593163170562">Datatype</th><th width="330">Description</th></tr></thead><tbody><tr><td><em>stackView</em></td><td><a href="/pages/-LMJNJAHEjHD4ToJEIAU">StackController</a></td><td>Pointer to the <a href="/pages/-LMJNJAHEjHD4ToJEIAU">StackController</a>.</td></tr><tr><td><em>scrollBar</em></td><td><a href="https://documentation.xojo.com/api/deprecated/scrollbar.html">ScrollBar</a></td><td>Pointer to the ScrollBar.</td></tr><tr><td><em>animated</em></td><td><a href="https://documentation.xojo.com/api/data_types/boolean.html">Boolean</a></td><td>Set Animation of the <a href="/pages/-LMJNJAHEjHD4ToJEIAU">StackController</a>.</td></tr><tr><td><em>UseNSScrollView</em></td><td><a href="https://documentation.xojo.com/api/data_types/boolean.html">Boolean</a> = False</td><td>Use NSScroller <strong>(macOS-only)</strong><br>If <code>UseNSScrollView = True</code> and you compile for Linux / Windows, the parameter will be ignored and the ScrollController uses the ScrollBar parameter.</td></tr></tbody></table>

**Sample Code**

MyScrollContainer1 `Open`-Event:

```xojo
Var nsScroller As Boolean

#If TargetMacOS Then
  // macOS-only
  nsScroller = True
#Else
  nsScroller = False
#Endif

Init(MyStackView1, ScrollBar1, True, nsScroller)
```

### RemoveView

Removes a View from the StackView.

**Parameters**

<table data-header-hidden><thead><tr><th width="150">Name</th><th width="150"></th><th width="447.7113523027281">Description</th></tr></thead><tbody><tr><td>Name</td><td>Datatype</td><td>Description</td></tr><tr><td><em>index</em></td><td><a href="https://documentation.xojo.com/api/data_types/integer.html">Integer</a></td><td>Removes the View at position index from the StackView.</td></tr></tbody></table>

## Properties

### Expanded As [Boolean](https://documentation.xojo.com/api/data_types/boolean.html) *(read-only)*

Returns the state of the StackController.

### UseAnimation As [Boolean](https://documentation.xojo.com/api/data_types/boolean.html)

The animation state of the StackController.

{% hint style="info" %}
The StackView Classes are able to shown within a [NSScrollView](https://developer.apple.com/documentation/appkit/nsstackview). This feature is macOS-only and there is no guarantee that the feature will work in coming Versions of Apple’s macOS. StackView uses the [XScrollView](https://www.pidog.com/share/nsscrollview.xojo_binary_project.zip) class of Jim McKay from [piDog Software](https://www.pidog.com).
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://xojo.gitbook.io/add-ons/stackview/version-2/details/scrollcontroller.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
