Loading...
Searching...
No Matches
JS::ScriptCommand Class Referencefinal

An undoable edit performed by a script. More...

Inheritance diagram for JS::ScriptCommand:
score::Command

Detailed Description

An undoable edit performed by a script.

A script can change state the engine knows nothing about - the QML side of an application, an external socket. This command lets such edits take part in undo, together with the engine edits around them.

The command carries a handler name and the payload for each direction, rather than the two closures the interface suggests: a command is serialized, both for the crash-recovery backup and for the network plug-in, and a QJSValue cannot be. Handlers are registered by name with Score.registerCommandHandler().

A handler that is not registered when the command runs - a backup restored before the script that owns it has loaded - is reported once and skipped.

Public Member Functions

 ScriptCommand (QString handler, QByteArray undoPayload, QByteArray redoPayload)
 
void undo (const score::DocumentContext &ctx) const override
 
void redo (const score::DocumentContext &ctx) const override
 
- Public Member Functions inherited from score::Command
virtual const CommandGroupKey & parentKey () const noexcept=0
 
virtual const CommandKey & key () const noexcept=0
 
QByteArray serialize () const
 
void deserialize (const QByteArray &)
 
virtual QString description () const =0
 

Additional Inherited Members

Member Function Documentation

◆ redo()

void JS::ScriptCommand::redo ( const score::DocumentContext &  ctx) const
overridevirtual

Implements score::Command.

◆ undo()

void JS::ScriptCommand::undo ( const score::DocumentContext &  ctx) const
overridevirtual

Implements score::Command.


The documentation for this class was generated from the following files: