Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -266,10 +266,19 @@
"pages": [
"scripting/api-reference/artboards/animation",
"scripting/api-reference/artboards/artboard",
"scripting/api-reference/artboards/focus-event",
"scripting/api-reference/artboards/key-phase",
"scripting/api-reference/artboards/keyboard-event",
"scripting/api-reference/artboards/listener-context",
"scripting/api-reference/artboards/node-data",
"scripting/api-reference/artboards/node-read-data",
"scripting/api-reference/artboards/none-event",
"scripting/api-reference/artboards/pointer-event",
"scripting/api-reference/artboards/view-model"
"scripting/api-reference/artboards/pointer-type",
"scripting/api-reference/artboards/reported-event",
"scripting/api-reference/artboards/text-input",
"scripting/api-reference/artboards/view-model",
"scripting/api-reference/artboards/view-model-change"
]
},
{
Expand Down
14 changes: 14 additions & 0 deletions scripting/api-reference/artboards/focus-event.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
title: FocusEvent
---

Represents a Focus event data


## Fields

### `isFocus`

Whether the element gained or lost focus


4 changes: 4 additions & 0 deletions scripting/api-reference/artboards/key-phase.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
title: KeyPhase
---

39 changes: 39 additions & 0 deletions scripting/api-reference/artboards/keyboard-event.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
title: KeyboardEvent
---

Represents a keyboard interaction.


## Fields

### `key`

The pressed key


### `shift`

Whether the shift modifier is pressed.


### `control`

Whether the control modifier is pressed.


### `alt`

Whether the alt modifier is pressed.


### `meta`

Whether the meta modifier is pressed.


### `phase`

Phase of the keyboard event (down, repeat or up).


177 changes: 177 additions & 0 deletions scripting/api-reference/artboards/listener-context.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
---
title: ListenerContext
---

Represents the context of a listener perform action


## Methods

### `isPointerEvent`

{/* isPointerEvent: (self: ListenerContext) -> boolean */}
<div class="signature">
```lua
isPointerEvent() -> boolean
```
</div>

returns true if the perform action was invoked through a pointer event


### `isKeyboardEvent`

{/* isKeyboardEvent: (self: ListenerContext) -> boolean */}
<div class="signature">
```lua
isKeyboardEvent() -> boolean
```
</div>

returns true if the perform action was invoked through a keyboard event


### `isTextInput`

{/* isTextInput: (self: ListenerContext) -> boolean */}
<div class="signature">
```lua
isTextInput() -> boolean
```
</div>

returns true if the perform action was invoked through a text input


### `isFocus`

{/* isFocus: (self: ListenerContext) -> boolean */}
<div class="signature">
```lua
isFocus() -> boolean
```
</div>

returns true if the perform action was invoked through a focus change


### `isReportedEvent`

{/* isReportedEvent: (self: ListenerContext) -> boolean */}
<div class="signature">
```lua
isReportedEvent() -> boolean
```
</div>

returns true if the perform action was invoked through a Rive event


### `isViewModelChange`

{/* isViewModelChange: (self: ListenerContext) -> boolean */}
<div class="signature">
```lua
isViewModelChange() -> boolean
```
</div>

returns true if the perform action was invoked through a view model change


### `isNone`

{/* isNone: (self: ListenerContext) -> boolean */}
<div class="signature">
```lua
isNone() -> boolean
```
</div>

returns true if the perform action is none of the known types


### `asPointerEvent`

{/* asPointerEvent: (self: ListenerContext) -> PointerEvent? */}
<div class="signature">
```lua
asPointerEvent() -> PointerEvent?
```
</div>

returns a pointer event if context is of type pointer event, null otherwise


### `asKeyboardEvent`

{/* asKeyboardEvent: (self: ListenerContext) -> KeyboardEvent? */}
<div class="signature">
```lua
asKeyboardEvent() -> KeyboardEvent?
```
</div>

returns a keyboard event if context is of type keyboard event, null otherwise


### `asTextInput`

{/* asTextInput: (self: ListenerContext) -> TextInput? */}
<div class="signature">
```lua
asTextInput() -> TextInput?
```
</div>

returns a text input event if context is of type text input event, null otherwise


### `asFocus`

{/* asFocus: (self: ListenerContext) -> FocusEvent? */}
<div class="signature">
```lua
asFocus() -> FocusEvent?
```
</div>

returns a focus event event if context is of type focus event, null otherwise


### `asReportedEvent`

{/* asReportedEvent: (self: ListenerContext) -> ReportedEvent? */}
<div class="signature">
```lua
asReportedEvent() -> ReportedEvent?
```
</div>

returns a reported event if context is of type reported evnet, null otherwise


### `asViewModelChange`

{/* asViewModelChange: (self: ListenerContext) -> ViewModelChange? */}
<div class="signature">
```lua
asViewModelChange() -> ViewModelChange?
```
</div>

returns a view model change if context is of type view model, null otherwise


### `asNone`

{/* asNone: (self: ListenerContext) -> NoneEvent? */}
<div class="signature">
```lua
asNone() -> NoneEvent?
```
</div>

returns a noop event if context is of type none, null otherwise


7 changes: 7 additions & 0 deletions scripting/api-reference/artboards/none-event.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
title: NoneEvent
---

Represents a reported event


5 changes: 5 additions & 0 deletions scripting/api-reference/artboards/pointer-event.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ The position of the pointer in local coordinates.
The unique identifier for the pointer.


### `type`

The type of event (pointerDown, pointerUp, click, pointerEnter, pointerMove, etc).


## Constructors

### `new`
Expand Down
4 changes: 4 additions & 0 deletions scripting/api-reference/artboards/pointer-type.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
title: PointerType
---

7 changes: 7 additions & 0 deletions scripting/api-reference/artboards/reported-event.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
title: ReportedEvent
---

Represents a reported event


14 changes: 14 additions & 0 deletions scripting/api-reference/artboards/text-input.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
title: TextInput
---

Represents a Text input data


## Fields

### `text`

The text passed as input


7 changes: 7 additions & 0 deletions scripting/api-reference/artboards/view-model-change.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
title: ViewModelChange
---

Represents a View model change data


38 changes: 37 additions & 1 deletion scripting/api-reference/interfaces/listener-action.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ end

### `perform`

{/* perform: (self: T, pointerEvent: PointerEvent) -> () */}
{/* perform: ((self: T, pointerEvent: PointerEvent) -> ())? */}
<div class="signature">
```lua
perform(self: T, pointerEvent: PointerEvent) -> ()
Expand All @@ -49,6 +49,7 @@ perform(self: T, pointerEvent: PointerEvent) -> ()

Called when the associated [State Machine Listener](/editor/state-machine/listeners) is triggered.
This method includes a [PointerEvent](/scripting/api-reference/artboards/pointer-event) parameter containing details about the triggering interaction.
**Deprecated.** Prefer `performAction` with [ListenerContext](/scripting/api-reference/artboards/listener-context); this overload may be removed.
```lua highlight={9,10,11,17}
type MyListenerAction = {}

Expand All @@ -71,3 +72,38 @@ end
```


### `performAction`

{/* performAction: ((self: T, listenerContext: ListenerContext) -> ())? */}
<div class="signature">
```lua
performAction(self: T, listenerContext: ListenerContext) -> ()
```
</div>

Called when the associated [State Machine Listener](/editor/state-machine/listeners) is triggered.
This method includes a [ListenerContext](/scripting/api-reference/artboards/listener-context) parameter containing details about the triggering interaction.
```lua highlight={9,10,11,17}
type MyListenerAction = {}

function init(self: MyListenerAction, context: Context): boolean
return true
end

-- Add your transition logic here.
-- `evaluate` is fired every frame while the transition is active.
-- Returning false prevents a transition, true allows a transition.
function performAction(self: MyListenerAction, listenerContext: ListenerContext)
return true
end

-- Return a factory function that Rive uses to build the Listener Action instance.
return function(): ListenerAction<MyListenerAction>
return {
init = init,
performAction = performAction,
}
end
```