pxt-ev3/fieldeditors/field_ports.ts

32 lines
1.1 KiB
TypeScript
Raw Normal View History

/// <reference path="../node_modules/pxt-core/localtypings/blockly.d.ts"/>
/// <reference path="../node_modules/pxt-core/built/pxtblocks.d.ts"/>
2017-12-25 02:46:58 +01:00
/// <reference path="../node_modules/pxt-core/built/pxtsim.d.ts"/>
export interface FieldPortsOptions extends pxtblockly.FieldImagesOptions {
columns?: string;
width?: string;
}
2017-12-25 02:46:58 +01:00
export class FieldPorts extends pxtblockly.FieldImages implements Blockly.FieldCustom {
public isFieldCustom_ = true;
2017-12-25 02:46:58 +01:00
constructor(text: string, options: FieldPortsOptions, validator?: Function) {
super(text, { blocksInfo: options.blocksInfo, sort: true, data: options.data }, validator);
2017-12-25 02:46:58 +01:00
this.columns_ = parseInt(options.columns) || 4;
this.width_ = parseInt(options.width) || 300;
this.setText = Blockly.FieldDropdown.prototype.setText;
this.updateWidth = (Blockly.Field as any).prototype.updateWidth;
this.updateTextNode_ = Blockly.Field.prototype.updateTextNode_;
}
2017-12-25 02:46:58 +01:00
trimOptions_() {
}
protected buttonClick_ = function (e: any) {
let value = e.target.getAttribute('data-value');
this.setValue(value);
Blockly.DropDownDiv.hide();
};
2017-12-25 02:46:58 +01:00
}