<!--
{
  "availability" : [
    "iOS: 17.4.0 -",
    "iPadOS: 17.4.0 -",
    "tvOS: 17.4.0 -",
    "visionOS: 1.1.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "BrowserEngineKit",
  "identifier" : "/documentation/BrowserEngineKit/BEDirectionalTextRange",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "BrowserEngineKit"
    ],
    "preciseIdentifier" : "c:@SA@BEDirectionalTextRange"
  },
  "title" : "BEDirectionalTextRange"
}
-->

# BEDirectionalTextRange

Modifications to text length based on its offset.

```
struct BEDirectionalTextRange
```

## Overview

This class encapsulates instructions that modify a text selection. In a given instance, the sign of [`length`](/documentation/BrowserEngineKit/BEDirectionalTextRange/length) determines the selection direction from its [`offset`](/documentation/BrowserEngineKit/BEDirectionalTextRange/offset). Positive length indicates moving the selection forward in the string, whereas a negative  [`length`](/documentation/BrowserEngineKit/BEDirectionalTextRange/length) moves the selection backward in the string. For example, applying a directional text range of `{ -6, -2 }` to the selection “world” in the string “Hello world” results in the selection, “Hel”.

## Topics

### Creating a directional text range

[`init()`](/documentation/BrowserEngineKit/BEDirectionalTextRange/init())

Creates an empty directional text range.

[`init(offset:length:)`](/documentation/BrowserEngineKit/BEDirectionalTextRange/init(offset:length:))

Creates a range for a text selection that also specifies a direction.

### Measuring text range

[`length`](/documentation/BrowserEngineKit/BEDirectionalTextRange/length)

The number of characters included in the directional text range.

[`offset`](/documentation/BrowserEngineKit/BEDirectionalTextRange/offset)

The starting position of the directional text range within the text.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)