> ## Documentation Index
> Fetch the complete documentation index at: https://docs.framesports.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# What a coding window can do

> Every call a MatchCoder coding window can make, in plain words, for coaches who build or change their own windows.

A coding window is the panel of buttons beside the video in MatchCoder. This page lists everything a window's buttons can ask MatchCoder to do. Use it when you build a window yourself, or when you ask **Ask Framesports** to build or change one and want to know what is possible.

## How does a window talk to MatchCoder?

A window's buttons call `matchCoder`, an object MatchCoder puts in every window. Each call below is written the way a button uses it, for example `matchCoder.addEvent({ category: "Tackle" })`. Ask Framesports works from this same list, so anything here is something you can ask it for.

On a match you can only watch, the calls that change codes are refused, and the window says why.

## Making codes

These calls cover making codes.

| Call | What it does |
| - | - |
| `matchCoder.addEvent(input, atSeconds?)` | Add one code at the playhead (or at atSeconds). |
| `matchCoder.code(input, atSeconds?)` | Add one code, the way a button press does, with its popup. |
| `matchCoder.addEvents([input, ...], atSeconds?)` | Add several codes from one press, all from the same moment. |
| `matchCoder.startEvent(input, atSeconds?)` | Start a code whose end comes with a second press. |
| `matchCoder.endEvent(eventId, leadOut?, atSeconds?)` | End a code that startEvent started. |
| `matchCoder.toggleEvent(input, leadOut?, atSeconds?)` | Start a code on the first press and end it on the next. |
| `matchCoder.getOpenEvents()` | List the codes started but not ended yet. |
| `matchCoder.updateEvent(eventId, { startSeconds?, endSeconds? })` | Move a code's start or end. |
| `matchCoder.replaceEvent(eventId, input)` | Swap a code for another over the same moment, as one undo step. |
| `matchCoder.deleteEvent(eventId)` | Take a code away with no Deleted popup. |

## Changing codes

These calls cover changing codes.

| Call | What it does |
| - | - |
| `matchCoder.addLabel(label, eventId?)` | Add a label to a code, or to the selected one. |
| `matchCoder.removeLabel(label, eventId?)` | Take a label off a code, or off every selected code. |
| `matchCoder.setLabels(labels, eventId?)` | Replace a code's labels, or every selected code's. |
| `matchCoder.setCategory(category, eventId?)` | Move a code to another row, or every selected code. |
| `matchCoder.updateEvents(ids, { category?, labels?, addLabels?, removeLabels? })` | Make the same change to several codes as one undo step. |
| `matchCoder.setField(key, value, eventId?)` | Fill one of the host's fields on a code. |
| `matchCoder.nextEvent(category)` | Select the next code in a row that still needs its field filled. |
| `matchCoder.setSpot(eventId, spot)` | Put a place on the pitch on a code, or clear it with null. |

## Rules the editor runs

These calls cover rules the editor runs.

| Call | What it does |
| - | - |
| `matchCoder.setLinkedCodes([{ when, create: { category, from, offset, durationSeconds? } }])` | Make one code also add another, from any way it is coded, in the same undo step. |
| `matchCoder.setWholeMatchRows(names)` | Keep a row's codes end to end over the whole match, from 0 to the final whistle. |
| `matchCoder.rowGaps(row)` | List the parts of the match a row leaves uncovered. |

## Reading the match

These calls cover reading the match.

| Call | What it does |
| - | - |
| `matchCoder.codes({ category?, fromSeconds?, toSeconds?, fields? })` | Read the match's codes, oldest first. |
| `matchCoder.rows()` | Read the timeline's rows in order, with their colours. |
| `matchCoder.labelsInUse()` | Read every label on the match's codes, with how many carry it. |
| `matchCoder.selection()` | Read which codes are selected on the timeline. |
| `matchCoder.gameInfo()` | Read the match's name, length and teams. |
| `matchCoder.cameras()` | Read the match's other cameras. |
| `matchCoder.camera()` | Read which camera is on screen. |
| `matchCoder.time()` | Read the playhead, in seconds. |
| `matchCoder.hostState()` | Read what the editor last told the window: theme, read-only, playhead and more. |

## The timeline and the editor

These calls cover the timeline and the editor.

| Call | What it does |
| - | - |
| `matchCoder.select(ids)` | Choose which codes are selected on the timeline. |
| `matchCoder.clearSelection()` | Select nothing. |
| `matchCoder.spotlight(eventId \| null)` | Highlight one code on the timeline and dim the rest. |
| `matchCoder.setRows([{ name, color?, hidden? }])` | Lay out the timeline's rows: their order, colours, and which stay out of the list. |
| `matchCoder.setTimelineVisible(visible)` | Show or hide the timeline. |
| `matchCoder.setPane({ visible?, badge? })` | Hide or show the window, with what its button says. |
| `matchCoder.setPanelWidth(width)` | Ask for the window's panel to be this wide. |
| `matchCoder.notify(popup \| null)` | Show a message at the top of the screen. |
| `matchCoder.openLink(path)` | Open a page of the host's own site in a new tab. |
| `matchCoder.focusWindow()` | Give the keyboard back to the window. |
| `matchCoder.ready()` | Say the window has loaded. |

## The video

These calls cover the video.

| Call | What it does |
| - | - |
| `matchCoder.play()` | Play the video. |
| `matchCoder.pause()` | Pause the video. |
| `matchCoder.seek(seconds)` | Move the video to a moment. |
| `matchCoder.setSpeed(rate)` | Play faster or slower, from 0.25 to 4. |
| `matchCoder.loop(start, end) / loop(null)` | Play a stretch over and over, or stop. |
| `matchCoder.setCamera(id \| null)` | Show one of the match's cameras, or the main one. |

## Keys

These calls cover keys.

| Call | What it does |
| - | - |
| `matchCoder.registerShortcuts(keys, names?)` | Say which keys belong to the window. |
| `matchCoder.declareCodes(categories)` | Say which codes the window's buttons make. |
| `matchCoder.captureKeys(keys \| null, { allow })` | For a moment, send only these keys to the window. |

## Places and boxes

These calls cover places and boxes.

| Call | What it does |
| - | - |
| `matchCoder.pitchSvg` | The rugby pitch drawn to scale, to put in an \<svg viewBox="0 0 1200 700">. |
| `matchCoder.spot(start, end?)` | Turn a place on the pitch, in metres, into text a code keeps. |
| `matchCoder.readSpot(text)` | Turn a kept place back into metres. |
| `matchCoder.drawBox({ atSeconds?, notVisible? })` | Ask the coach to draw a box round a player on the video. |
| `matchCoder.cancelBox()` | Stop asking for a box. |
| `matchCoder.offerDrawChoices(choices)` | Offer a few choices while a box is drawn, and say which was picked. |

## Kept values

These calls cover kept values.

| Call | What it does |
| - | - |
| `matchCoder.gameValue(key)` | Read a value kept for the whole match. |
| `matchCoder.setGameValue(key, value)` | Keep a value for the whole match, or clear it with null. |
| `matchCoder.setup(key)` | Read the window's own set-up, kept for every match. |
| `matchCoder.setSetup(key, value)` | Keep part of the window's set-up, or clear it with null. |

## Frequently Asked Questions

**Can one button make two codes?** Yes. Use `matchCoder.addEvents` for two codes from one press, or `matchCoder.setLinkedCodes` so a code always brings another with it, however it is coded. See **Rules the editor runs** above.

**Can a row cover the whole match, like pitch zones or possession?** Yes. `matchCoder.setWholeMatchRows` keeps that row's codes end to end from the start of the match to the end, and `matchCoder.rowGaps` shows any part left uncovered.

**Does Undo take back what a window did?** Yes. A press, and every code its rules add or move, comes back with one **Undo**.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.