Class: wcPlayEditor

wcPlayEditor


new wcPlayEditor(container [, options])

Provides a visual interface for editing a Play script. Requires HTML5 canvas.

Parameters:
Name Type Argument Description
container external:jQuery~Object | external:jQuery~Selector | external:domNode The container element.
options wcPlayEditor~Options <optional>
Custom options.
Source:

Methods


function __drawDetailsPopup(node)

Draws the detail popup box for the node.

Parameters:
Name Type Description
node wcNode The node to draw for.
Source:

function __drawPalettePopup(pos [, linkNode] [, linkName] [, linkType] [, onFinished])

Draws the popup that allows the user to select a node type.

Parameters:
Name Type Argument Description
pos wcPlay~Coordinates The position to center the popup.
linkNode wcNode <optional>
If supplied, the source node to link with.
linkName string <optional>
If supplied, the name of the source link.
linkType wcNode.LINK_TYPE <optional>
If supplying a node, this is the type of link you are attaching to.
onFinished wcPlayEditor~OnPalettePopupFinished <optional>
A callback function to call when the popup has resolved.
Source:

function center()

Positions the canvas view to the center of all nodes.

Source:

function clearModified()

Clears the modified state of the current script. Note, this is done automatically when saving the script, use this only under special circumstances.

Source:

function engine( [engine]) -> wcPlay

Gets, or Sets the wcPlay engine that this renderer will render.

Parameters:
Name Type Argument Description
engine wcPlay <optional>
If supplied, will assign a new wcPlay engine to render.
Source:
Returns:
- The current wcPlay engine.
Type
wcPlay

function error(args)

Outputs an error message.

Parameters:
Name Type Argument Description
args string <repeatable>
The log messages.
Source:

function focus(nodes)

Scrolls the canvas view until a given set of nodes are within view.

Parameters:
Name Type Description
nodes wcNode A list of nodes to focus the view on.
Source:

function focusRect(rect)

Scrolls the canvas view and centers on a given bounding rectangle.

Parameters:
Name Type Description
rect wcPlayEditor~Rect The rectangle to focus on.
Source:

function isModified() -> boolean

Retrieves whether unsaved changes exist in the current script.

Source:
Returns:
- Whether the script has unsaved changes.
Type
boolean

function log(args)

Outputs a log message.

Parameters:
Name Type Argument Description
args string <repeatable>
The log messages.
Source:

Retrieves the menu instance.

Source:
Returns:
- The wcMenu object.
Type
wcMenu

function onBeforeImport(func) -> boolean

Binds an event handler for when we are about to save our script.

Parameters:
Name Type Description
func function Assigns the function to handle this event.
Source:
Returns:
- Success or failure.
Type
boolean

function onBeforeLoad(func) -> boolean

Binds an event handler for when we are about to save our script.

Parameters:
Name Type Description
func function Assigns the function to handle this event.
Source:
Returns:
- Success or failure.
Type
boolean

function onBeforeSave(func) -> boolean

Binds an event handler for when we are about to save our script.

Parameters:
Name Type Description
func function Assigns the function to handle this event.
Source:
Returns:
- Success or failure.
Type
boolean

function onBeginUndoGroup(description)

Event that is called to begin an undo manager group operation.

Parameters:
Name Type Description
description string The description of the undo event.
Source:

function onDisconnectEntryChains(node, linkName)

Disconnects all chains attached to a node's entry link.

Parameters:
Name Type Description
node wcNode The node to disconnect from.
linkName string The name of the link.
Source:

function onDisconnectExitChains(node, linkName)

Disconnects all chains attached to a node's exit link.

Parameters:
Name Type Description
node wcNode The node to disconnect from.
linkName string The name of the link.
Source:

function onDisconnectInputChains(node, linkName)

Disconnects all chains attached to a node's input link.

Parameters:
Name Type Description
node wcNode The node to disconnect from.
linkName string The name of the link.
Source:

function onDisconnectOutputChains(node, linkName)

Disconnects all chains attached to a node's output link.

Parameters:
Name Type Description
node wcNode The node to disconnect from.
linkName string The name of the link.
Source:

function onEndUndoGroup()

Event that is called to end an undo manager group operation.

Source:

function onImported(func) -> boolean

Binds an event handler for when we are about to save our script.

Parameters:
Name Type Description
func function Assigns the function to handle this event.
Source:
Returns:
- Success or failure.
Type
boolean

function onLoaded(func) -> boolean

Binds an event handler for when we are about to save our script.

Parameters:
Name Type Description
func function Assigns the function to handle this event.
Source:
Returns:
- Success or failure.
Type
boolean

function onResized()

Event that is called when the container view is resized.

Source:

function onSaved(func) -> boolean

Binds an event handler for when we are about to save our script.

Parameters:
Name Type Description
func function Assigns the function to handle this event.
Source:
Returns:
- Success or failure.
Type
boolean

function triggerEvent(eventName, args)

Triggers a previously bound event handler.

Parameters:
Name Type Description
eventName string The name of the event to trigger.
args Array.<Object> Any parameter arguments you wish to send to the triggered event nodes. These parameters are based on the node being triggered.
Source:

<inner> function MenuDescriptionFunc(editor, engine)

A callback that retrieves the description string for a menu option.

Parameters:
Name Type Description
editor wcPlayEditor The instance of the editor invoking the menu option.
engine wcPlay The instance of the script engine being viewed by the editor.
Source:

<inner> function MenuIconFunc(editor, engine)

A callback that retrieves the icon class for a menu option.

Parameters:
Name Type Description
editor wcPlayEditor The instance of the editor invoking the menu option.
engine wcPlay The instance of the script engine being viewed by the editor.
Source:

Type Definitions


typedef var BoundingData

Bounding information for links on a node.

Type:
  • Object
Properties:
Name Type Description
rect wcPlayEditor~Rect The bounding rectangle.
point wcPlay~Coordinates The anchor point where lines will attach to this link.
name String The name of the bounded object.
Source:

typedef var CategoryOptions

Category display options.

Type:
  • Object
Properties:
Name Type Description
items Array.<String> A list of categories to show in the palette.
isBlacklist Boolean If true, the items list will be treated as a blacklist of categories to hide.
Source:

typedef var DrawNodeData

Data associated with a drawn node.

Type:
  • Object
Properties:
Name Type Description
node wcNode The node instance.
rect wcPlayEditor~Rect Bounding rectangle of the node (not including links that stick out).
entryBounds Array.<wcPlayEditor~BoundingData> Bounding data of entry links.
exitBounds Array.<wcPlayEditor~BoundingData> Bounding data of exit links.
inputBounds Array.<wcPlayEditor~BoundingData> Bounding data of property input links.
outputBounds Array.<wcPlayEditor~BoundingData> Bounding data of property output links.
valueBounds Array.<wcPlayEditor~BoundingData> Bounding data of property value text.
initialBounds Array.<wcPlayEditor~BoundingData> Bounding data of property initial value text.
Source:

typedef var MenuOptions

Custom options for a menu option.

Type:
  • Object
Properties:
Name Type Argument Description
icon String | wcPlayEditor~MenuIconFunc <optional>
A classname to apply as an icon for the option. If this is a function, it will be called during the update call and should return the icon class.
description|wcPlayEditor~MenuDescriptionFunc String <optional>
The description to show as a tooltip for this option.
itemIndex Number <optional>
An insertion index to insert the item within the menu category, default is to append to the end.
categoryIndex Number <optional>
If this creates a new category, it will be inserted at this index in the top level menu.
toolbarIndex Boolean <optional>
If supplied, creates a toolbar button for this option and inserts it in the tab bar at the specified index. -1 will append it to the end.
hotkeys String <optional>
A string that describes hotkeys for your control, the format is 'Ctrl+Z' or 'Alt+Shift+L,Shift+L' for multiple.
condition function <optional>
A function to call during the update to determine if the menu option should be enabled or disabled. Return false to disable the option.
Source:

typedef function OnMenuActivated(event, editor, engine)

On click handler for menu and toolbar options.

Parameters:
Name Type Description
event Object The mouse click event object.
editor wcPlayEditor The instance of the editor invoking the menu option.
engine wcPlay The instance of the script engine being viewed by the editor.
Source:

typedef var OnPalettePopupFinished

A callback handler when a node has been created.

Source:

typedef var Options

Custom options available when constructing a new wcPlay instance.

Type:
  • Object
Properties:
Name Type Argument Default Description
readOnly Boolean <optional>
false If true, the script will not be editable.
playable Boolean <optional>
true Whether the script can be played using the live debugger.
category wcPlayEditor~CategoryOptions <optional>
Options that determine what categories appear in the palette. By default, all categories are visible.
Source:

typedef var Rect

The 2D bounds of a rectangle.

Type:
  • Object
Properties:
Name Type Description
top Number
left Number
width Number
height Number
Source: