Move

@objcMembers public final class Move: BlocklyEvent

Event fired when a block is moved on the workspace, or its parent connection is changed.

This event must be created before the block is moved to capture the original position. After the move has been completed in the workspace, capture the updated position or parent using recordNew(forBlock:).

  • The event type for BlocklyEvent.Move objects.

    Declaration

    Swift

    public static let EVENT_TYPE = "move"
  • The previous parent block ID of the target block. If nil, it indicates the target block was not previously connected to a parent.

    Declaration

    Swift

    public fileprivate(set) var oldParentID: String?
  • If oldParentID is not nil, this is the input name of the previous parent block that the target block was connected to.

    Declaration

    Swift

    public fileprivate(set) var oldInputName: String?
  • The previous position of the target block. If nil, it indicates that the target block was previously connected to a parent block.

    Declaration

    Swift

    public fileprivate(set) var oldPosition: WorkspacePoint?
  • The new parent block ID of the target block. If nil, it indicates the target block is not connected to a parent.

    Declaration

    Swift

    public var newParentID: String?
  • If newParentID is not nil, this is the input name of the parent block that the target block is connected to.

    Declaration

    Swift

    public var newInputName: String?
  • The new position of the target block. If nil, it indicates that the target block is connected to a parent block.

    Declaration

    Swift

    public var newPosition: WorkspacePoint?
  • Constructs a BlocklyEvent.Move signifying the movement of a block on the workspace.

    Declaration

    Swift

    public init(
          workspaceID: String, blockID: String, oldParentID: String?, oldInputName: String?,
          oldPosition: WorkspacePoint?)
  • Constructs a BlocklyEvent.Move from the JSON serialized representation.

    Throws

    BlocklyError: Thrown when the JSON could not be parsed into a BlocklyEvent.Move object.

    Declaration

    Swift

    public init(json: [String: Any]) throws
  • Constructs a BlocklyEvent.Move signifying the movement of a block on the workspace. The current positional values of the block are recorded as the old values for the event.

    Declaration

    Swift

    public convenience init(workspace: Workspace, block: Block)
  • Updates the event’s new values to capture the current state of a given block.

    Note

    If the given block is nil or its UUID doesn’t match the event’s blockID, then no values are captured.

    Declaration

    Swift

    public func recordNewValues(forBlock block: Block?)