# RollOverBubbling

### Introduction

The RollOverBubbling event is raised whenever the cursor rolls over an InteractiveGue. A roll is defined as the cursor being positioned over the bounds of an InteractiveGue when the cursor's X or Y values have changed.

This event is raised top-down, with children object having the first opportunity to handle the event. If the event is not handled by the child, then parents have the opportunity to handle the event. If the RoutedEventArgs Handled property is set to true, then no parents receive the event.

### Code Example - Scrolling with Cursor Press

The following code shows how to implement ListBox scrolling using the cursor when the cursor is pressed.

```csharp
// Initialize
// This will work with any item that has a scrollbar, such as
// ListBox, ItemsControl, and ScrollViewer
listBox.Visual.RollOverBubbling += (sender, args) =>
{
    var cursor = GumService.Default.Cursor;

    // Only handle this if the crusor is pressed
    if (cursor.PrimaryDown)
    {
        // we can get the vertical scroll bar through visuals:
        var scrollBarVisual = (InteractiveGue) listBox.Visual.GetChildByNameRecursively(
            ListBox.VerticalScrollBarInstanceName);

        // InteractiveGues provide a FormsControlAsObject property to access
        // the forms object.
        var scrollBar = (ScrollBar)scrollBarVisual.FormsControlAsObject;

        // Change the ScrollBar's value which results in the ListBox scrolling.
        scrollBar.Value -= cursor.YChange /
            global::RenderingLibrary.SystemManagers.Default.Renderer.Camera.Zoom;

        // set the Handled property true so children do not get this
        args.Handled = true;
    }
};

```

<figure><img src="/files/vr8p9MgBTRuiCaMBo7hv" alt=""><figcaption><p>Scrolling a ListBox by pressing and moving the cursor</p></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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://docs.flatredball.com/gum/code/gum-code-reference/interactivegue/rolloverbubbling.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.
