KcdMp.onPlayerCursor
Registers a function that is told when the player brings up their cursor or takes it away.
The player brings up their cursor with the cursor key (left Alt unless they picked another in the launcher), and a client
script with its SetCursorShown. fn(shown) is called at once with the current state, then again at every change. While
the cursor is up and no frame holds the mouse cursor, the interface’s own parts (the chat, the scoreboard …) take the
clicks; a page that wants them asks for the cursor itself - KcdMp.focus({ cursor: true }) - and gives it back when the
player’s cursor goes. The cursor goes away by itself when one of the game’s own menus opens and at a load.
Syntax
Section titled “Syntax”KcdMp.onPlayerCursor(fn)| Parameter | Type | |
|---|---|---|
fn |
(shown: boolean) => void |
called with true while the cursor is up, false while it is not |
Returns
Section titled “Returns”() => void - a function that takes the handler off again
Example
Section titled “Example”KcdMp.onPlayerCursor((shown) => { document.body.classList.toggle("clickable", shown); KcdMp.focus({ cursor: shown }).catch(() => {});});See also
Section titled “See also”KcdMp.focus · KcdMp.blur · KcdMp.mock.playerCursor · the Focus and visibility group of the index
