mirror of
https://github.com/google/blockly.git
synced 2026-05-13 15:40:11 +02:00
b0475b0c68
* fix: Remove spurious blank lines Remove extraneous blank lines introduced by deletion of 'use strict'; pragmas. Also fix the location of the goog.declareModuleId call in core/utils/array.ts. * fix: Add missing double-blank-line before body of modules Our convention is to have two blank lines between the imports (or module ID, if there are no imports) and the beginning of the body of the module. Enforce this. * fix: one addition format error for PR #6243
79 lines
2.1 KiB
TypeScript
79 lines
2.1 KiB
TypeScript
/**
|
|
* @license
|
|
* Copyright 2020 Google LLC
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
/**
|
|
* @fileoverview Events fired as a result of element select action.
|
|
*/
|
|
|
|
/**
|
|
* Events fired as a result of element select action.
|
|
* @class
|
|
*/
|
|
import * as goog from '../../closure/goog/goog.js';
|
|
goog.declareModuleId('Blockly.Events.Selected');
|
|
|
|
import * as registry from '../registry.js';
|
|
|
|
import {UiBase} from './events_ui_base.js';
|
|
import * as eventUtils from './utils.js';
|
|
|
|
|
|
/**
|
|
* Class for a selected event.
|
|
* @alias Blockly.Events.Selected
|
|
*/
|
|
export class Selected extends UiBase {
|
|
oldElementId?: string|null;
|
|
newElementId?: string|null;
|
|
override type: string;
|
|
|
|
/**
|
|
* @param opt_oldElementId The ID of the previously selected element. Null if
|
|
* no element last selected. Undefined for a blank event.
|
|
* @param opt_newElementId The ID of the selected element. Null if no element
|
|
* currently selected (deselect). Undefined for a blank event.
|
|
* @param opt_workspaceId The workspace identifier for this event.
|
|
* Null if no element previously selected. Undefined for a blank event.
|
|
*/
|
|
constructor(
|
|
opt_oldElementId?: string|null, opt_newElementId?: string|null,
|
|
opt_workspaceId?: string) {
|
|
super(opt_workspaceId);
|
|
|
|
/** The id of the last selected element. */
|
|
this.oldElementId = opt_oldElementId;
|
|
|
|
/** The id of the selected element. */
|
|
this.newElementId = opt_newElementId;
|
|
|
|
/** Type of this event. */
|
|
this.type = eventUtils.SELECTED;
|
|
}
|
|
|
|
/**
|
|
* Encode the event as JSON.
|
|
* @return JSON representation.
|
|
*/
|
|
override toJson(): AnyDuringMigration {
|
|
const json = super.toJson();
|
|
json['oldElementId'] = this.oldElementId;
|
|
json['newElementId'] = this.newElementId;
|
|
return json;
|
|
}
|
|
|
|
/**
|
|
* Decode the JSON event.
|
|
* @param json JSON representation.
|
|
*/
|
|
override fromJson(json: AnyDuringMigration) {
|
|
super.fromJson(json);
|
|
this.oldElementId = json['oldElementId'];
|
|
this.newElementId = json['newElementId'];
|
|
}
|
|
}
|
|
|
|
registry.register(registry.Type.EVENT, eventUtils.SELECTED, Selected);
|