> For the complete documentation index, see [llms.txt](https://docs.febucci.com/text-animator-unreal/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.febucci.com/text-animator-unreal/typewriter/trigger-events-when-typing.md).

# Trigger Events when typing

Events are special tags that let you send messages (delegates with a FEventMarker parameter) to any listener, once the typewriter has reached a specific part of the text. *(For this reason, events work only if the typewriter is enabled)*

<figure><img src="/files/tiFfa2C8N3FO4uciCVTS" alt="textanimatorgif2febucci"><figcaption><p>Scene 'Example 3 - Events'</p></figcaption></figure>

***

## Overview <a href="#overview" id="overview"></a>

You can write events in your text by using rich text tags.

### Formatting <a href="#formatting" id="formatting"></a>

Event’s messages are preceded by a question mark, like this: `<?eventMessage>`.

**Example:** To call an event named ‘shakeCamera’, write: `<?shakeCamera>`

* 👍🏻 An event can have any kind of tag, including built-in effect’s ones.
* ⚠️ Events are case sensitive. Writing `<?camshake>` is not the same as writing `<?camShake>`. Be careful! (or use the `FString.ToLower()` method in your scripts to account for that.)

### Parameters <a href="#parameters" id="parameters"></a>

Events can have one or multiple parameters (starting with the `=` sign for the first, and then separating the others with a comma `,`), to allow you to send multiple data to your code or Blueprints.

* One parameter: `<?eventID=parameter1>`, will result in a message “eventID” and one parameter “parameter1”.
* Multiple parameters: `<?eventID=p1,p2>`, will result in a message “eventID” and parameters “p1” and “p2”.

***

## Listening to events from C++ <a href="#listening-to-events" id="listening-to-events"></a>

The code that you want to listen for events/messages must subscribe to the `FOnMessage` delegate inside the `UTypewriterCore` class.

Example:

```cpp
//Inside your C++ class (for example, inside a custom UActorComponent)

#pragma once

#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
#include "TextAnimatorFebucci/Public/Typewriter/TypewriterCore.h"
#include "TextAnimatorFebucci/Public/Widgets/AnimTextBlock.h"
#include "YourClassName.generated.h"

UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent))
class YOURPROJECT_API UYourClassName : public UActorComponent
{
    GENERATED_BODY()

public:
    UAnimTextBlock* AnimatedText;

//Adds and removes listening to callback
protected:
    virtual void BeginPlay() override 
    {
        Super::BeginPlay();
        
        if (AnimatedText)
        {
            AnimatedText->Typewriter->OnMessage.AddDynamic(this, &UYourClassName::OnTypewriterMessage);
        }
     }
    virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override
    {
        if (AnimatedText)
        {
            AnimatedText->Typewriter->OnMessage.RemoveDynamic(this, &UYourClassName::OnTypewriterMessage);
        }
    
        Super::EndPlay(EndPlayReason);
    }

    //Does stuff based on delegate
    UFUNCTION()
    void OnTypewriterMessage(const FEventMarker& EventMarker)
    {
        if (EventMarker.Name.Equals(TEXT("something"), ESearchCase::IgnoreCase))
        {
            // Do something
        }
    }
```

👍🏻 Note how the “message” string has no ‘<‘, ‘?’ and ‘>’ characters, but only contains the message.

## Listening to events from Blueprints <a href="#listening-to-events" id="listening-to-events"></a>

Subscribing to events from Blueprints is also straightforward. Assuming you have a reference to an AnimTextBlock in one of your custom widgets, just bind an event to the `OnMessage` delegate of its typewriter on On Initialized and unbind it on Destruct.

Example:

<figure><img src="/files/XZI6hYrDU8XxUmrJNFij" alt=""><figcaption></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, and the optional `goal` query parameter:

```
GET https://docs.febucci.com/text-animator-unreal/typewriter/trigger-events-when-typing.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
