Class ScrollView2D

Class Hierarchy

Use the Scroll View 2D node to create an input plane to enable user input from gestures. For example, you can use the scroll message with its parameters generated by a Scroll View node to move a map plane or rotate a mesh.

When you create a Scroll View node it does not have a visual shape and does not necessarily need visible content. You can use a Scroll View node as an interactive surface even when it does not have visible content. When a user interacts with a Scroll View node, the action generates a message that travels to the Scroll View node where you can define the behavior for that message.

Relative position within a Scroll View is called scroll position and a position to which a Scroll View is going to scroll is called scroll target. Scroll View nodes report changes of their scroll position using the ScrollViewConcept::ScrolledMessage message. For example, you can add actions to react to these messages to set the position of a node controlled by a Scroll View node according to the scrolling. Current scroll position can also be read from ScrollPositionProperty.

Scroll View 2D node has location, position, and size in 2D space. It registers user input in 2D coordinates within the area defined by the size of the Scroll View 2D node. Take this into account when you design interaction with a Scroll View 2D. For example, if you rotate a Scroll View 2D node, the scroll input gets distorted.

Finding out when scrolling starts or ends

You can find out when the scrolling of a Scroll View node starts or ends by subscribing to the Scroll View messages. Scroll View nodes send:

  • ScrollStartedMessage message when scrolling starts, regardless of how the scrolling started.
  • ScrollFinishedMessage message when scrolling ends, regardless of how the scrolling ended. Scrolling ends when the interpolators reach the target values and the current position no longer changes.
  • UserScrollStartedMessage message when user interaction causes the scrolling to start.
  • UserScrollFinishedMessage message when user interaction causes the scrolling to end. At this point the user interaction ended, but the scrolling movement can still continue.

Setting the scroll position of a Scroll View node

You can scroll to a specific position in a Scroll View node by sending a SetScrollMessage message or by setting the value of the ScrollPositionProperty to that Scroll View. When you send a SetScrollMessage message or set the value of the ScrollPositionProperty to a Scroll View, that Scroll View goes to that position immediately. If scrolling to a position is in progress and the scroll target is different from the current scroll position, this message does not stop that scrolling.

When you want to change the values towards which the Scroll View interpolators are going, set the scroll target for that Scroll View. If the scroll target and the current scroll position do not match, a Scroll View node interpolates the scroll values towards the scroll target values. X and Y scroll values use separate interpolators and velocities.

See also
See also

Use a Scroll View 2D to get user input from scroll gestures in 2D space.

Inherits properties and message types from ScrollView2DMetadata.

Synopsis

Methods
create()

Creates a Scroll View node

ScrollView2D.ScrollView2D:create(name)

Creates a Scroll View node.

Parameters
name (string)

The name of the node.