# Title

`com.jsmacrosce.jsmacros.client.api.event.impl.EventTitle`

**Since:** 1.2.7

**Cancellable:** Yes. Call `event.cancel()` in a handler before releasing the event lock.

Fires when the client receives a title, subtitle, or action-bar message; [type](#com.jsmacrosce.jsmacros.client.api.event.impl.EventTitle_type) identifies
 the HUD line. Action-bar messages include client-side system messages. A joined listener can
 replace the message with `setMessage(...)`, assign `null`, or cancel the
 event to suppress it.  
 ```js
JsMacros.on("Title", true, JavaWrapper.methodToJava(function (event) {
  if (event.getMessage() === null) {
    return;  
  }
  if (event.type === "ACTIONBAR") {
    if (event.getMessage().getString().includes("moved too quickly")) {
      // hide the lag message, the game shows nothing in its place
      event.cancel();  
      return;  
    }
  }
  if (event.type === "TITLE") {
    // keep the line but put something else in it
    event.setMessage(Chat.createTextHelperFromString("hello"));  
  }
}))
 ```

## Constructors

### new EventTitle {#com.jsmacrosce.jsmacros.client.api.event.impl.EventTitle_constructor-String-Component-}

```js
new EventTitle(String type, Component message)
```

Initializes this event with a HUD line identifier and its supplied component; this does not dispatch or display the event.  
 The identifier is stored verbatim and is not checked against `TITLE`, `SUBTITLE`, or `ACTIONBAR`.  
 The component is wrapped by [TextHelper.wrap(Component)](../../../../../../../../classes/com/jsmacrosce/jsmacros/client/api/helper/TextHelper.md#com.jsmacrosce.jsmacros.client.api.helper.TextHelper_wrap-Component-) without cloning it; a `null` component produces a `null` helper.

**Parameters:**
- `type`: supplied HUD line identifier, conventionally `TITLE`, `SUBTITLE`, or `ACTIONBAR`
- `message`: supplied component, or `null`

## Fields

### message {#com.jsmacrosce.jsmacros.client.api.event.impl.EventTitle_message}

```js
message: TextHelper
```

Message to display, wrapped in a [TextHelper](../../../../../../../../classes/com/jsmacrosce/jsmacros/client/api/helper/TextHelper.md); assigning a replacement changes the
 displayed text. `null` or cancelling passes no component to the game. For action-bar
 messages, the usual display timer is still reset when suppressed.

**Deprecated:** Removal in 3.0.0: Use [getMessage()](#com.jsmacrosce.jsmacros.client.api.event.impl.EventTitle_getMessage-) and [setMessage(TextHelper)](#com.jsmacrosce.jsmacros.client.api.event.impl.EventTitle_setMessage-TextHelper-) instead.

### type {#com.jsmacrosce.jsmacros.client.api.event.impl.EventTitle_type}

```js
type: String
```

Identifies the message's HUD line: `'TITLE'`, `'SUBTITLE'`, or `'ACTIONBAR'`.  
 Client-side system messages use `'ACTIONBAR'`.

## Methods

### getMessage {#com.jsmacrosce.jsmacros.client.api.event.impl.EventTitle_getMessage-}

```js
getMessage(): TextHelper
```

Returns the message to display, or `null` when no component will be passed to the game.

**Returns:** the current message helper, or `null`

**Since:** 2.2.0

### setMessage {#com.jsmacrosce.jsmacros.client.api.event.impl.EventTitle_setMessage-TextHelper-}

```js
setMessage(TextHelper message): void
```

Replaces the text to display. `null` or cancelling passes no component to the game. For
 action-bar messages, the usual display timer is still reset when suppressed.

**Parameters:**
- `message`: replacement helper, or `null` to suppress the line

**Since:** 2.2.0

### toString {#com.jsmacrosce.jsmacros.client.api.event.impl.EventTitle_toString-}

```js
toString(): String
```

Returns a diagnostic string containing the event name, type, and current message helper's string representation.  
 The format is `%s:{"type": "%s", "message": "%s"}`; it is not JSON serialization, and values are not escaped.  
 A `null` current message is represented as the literal `null` inside the quoted message field.

**Returns:** diagnostic text with the event name, type, and current message helper representation
