Files
blockly/core/events/events_selected.js
Monica Kozbial 40ef586260 Refactoring Ui events in core (#4418)
* Ui events base (#4370)

* Add constants for new ui event types

* Add property to indicate an event as UI event

* Click events (#4372)

* Creating new ui base class.

* Refactor theme event (#4391)

* Add themeName property to theme event

* Refactor marker move events. (#4389)

* Refactor trashcan open event (#4392)

* Refactor selected event (#4387)

* Refactor toolbox item change event (#4394)

* Refactor bubble open events (#4390)

* Refactor block drag event (#4388)

* Viewport events (#4395)

* Fix event filtering for ui events (#4401)

* Move events to new directory and rename Ui events base (#4400)

* Move events to new directory and rename Ui events base

* Add missing fromJson implementation for click event (#4410)

* Adding serialization tests for events

* Zoom controls event (#4407)

* Refactor zoom event

* Rename IS_UI_EVENT to isUiEvent
2020-11-04 14:43:54 -08:00

78 lines
2.2 KiB
JavaScript

/**
* @license
* Copyright 2020 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Events fired as a result of element select action.
* @author kozbial@google.com (Monica Kozbial)
*/
'use strict';
goog.provide('Blockly.Events.Selected');
goog.require('Blockly.Events');
goog.require('Blockly.Events.UiBase');
goog.require('Blockly.registry');
goog.require('Blockly.utils.object');
/**
* Class for a Selected event.
* @param {?string=} opt_oldElementId The id of the previously selected
* element. Null if no element last selected. Undefined for a blank event.
* @param {?string=} opt_elementId The id of the selected element. Null if no
* element currently selected (deselect). Undefined for a blank event.
* @param {string=} opt_workspaceId The workspace identifier for this event.
* Null if no element previously selected. Undefined for a blank event.
* @extends {Blockly.Events.UiBase}
* @constructor
*/
Blockly.Events.Selected = function(opt_oldElementId, opt_elementId,
opt_workspaceId) {
Blockly.Events.Selected.superClass_.constructor.call(this, opt_workspaceId);
/**
* The id of the last selected element.
* @type {?string|undefined}
*/
this.oldElementId = opt_oldElementId;
/**
* The id of the selected element.
* @type {?string|undefined}
*/
this.elementId = opt_elementId;
};
Blockly.utils.object.inherits(Blockly.Events.Selected, Blockly.Events.UiBase);
/**
* Type of this event.
* @type {string}
*/
Blockly.Events.Selected.prototype.type = Blockly.Events.SELECTED;
/**
* Encode the event as JSON.
* @return {!Object} JSON representation.
*/
Blockly.Events.Selected.prototype.toJson = function() {
var json = Blockly.Events.Selected.superClass_.toJson.call(this);
json['oldElementId'] = this.oldElementId;
json['elementId'] = this.elementId;
return json;
};
/**
* Decode the JSON event.
* @param {!Object} json JSON representation.
*/
Blockly.Events.Selected.prototype.fromJson = function(json) {
Blockly.Events.Selected.superClass_.fromJson.call(this, json);
this.oldElementId = json['oldElementId'];
this.elementId = json['elementId'];
};
Blockly.registry.register(Blockly.registry.Type.EVENT, Blockly.Events.SELECTED,
Blockly.Events.Selected);