# ScrollController

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

## Methods

| [AddView](#addview-view-as-viewcontroller-index-as-integer-1) | [Expand](#expand-value-as-boolean)                                                                                          |
| ------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- |
| [GetViews](#getviews-as-viewcontroller)                       | [Init](#init-stackview-as-stackcontroller-scrollbar-as-scrollbar-animated-as-boolean-true-usensscrollview-as-boolean-false) |
| [RemoveView](#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="viewcontroller">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="stackcontroller">StackController</a>.</td></tr></tbody></table>

**Sample Code**

PushButton1 `Action`-Event:

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

### GetViews As [ViewController()](viewcontroller)

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="stackcontroller">StackController</a></td><td>Pointer to the <a href="stackcontroller">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="stackcontroller">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 %}
