pxt-calliope/fieldeditors/field_gestures.ts
Amerlander 80845a32f9
Updates (#96)
* Update gesture field for new Blockly renderer (#2658)

* Update gesture field for new Blockly renderer

* Bump pxt-core to 5.36.1

* percent sign for motors block

* shims & strings

Co-authored-by: Amerlander <gitkraken@juriwolf.de>
2020-04-20 19:10:27 -07:00

32 lines
1.1 KiB
TypeScript

/// <reference path="../node_modules/pxt-core/localtypings/blockly.d.ts"/>
/// <reference path="../node_modules/pxt-core/built/pxtblocks.d.ts"/>
/// <reference path="../node_modules/pxt-core/built/pxtsim.d.ts"/>
export interface FieldGesturesOptions extends pxtblockly.FieldImagesOptions {
columns?: string;
width?: string;
}
export class FieldGestures extends pxtblockly.FieldImages implements Blockly.FieldCustom {
public isFieldCustom_ = true;
constructor(text: string, options: FieldGesturesOptions, validator?: Function) {
super(text, options, validator);
this.columns_ = parseInt(options.columns) || 4;
this.width_ = parseInt(options.width) || 350;
this.addLabel_ = true;
this.setText = Blockly.FieldDropdown.prototype.setText;
this.updateSize_ = (Blockly.Field as any).prototype.updateSize_;
}
trimOptions_() {
}
protected buttonClick_ = function (e: any) {
let value = e.target.getAttribute('data-value');
this.setValue(value);
Blockly.DropDownDiv.hide();
};
}