pxt-core
Version:
Microsoft MakeCode provides Blocks / JavaScript / Python tools and editors
50 lines (49 loc) • 1.63 kB
TypeScript
/// <reference path="../../pxtlib.d.ts" />
import * as Blockly from "blockly";
import { FieldCustom, FieldCustomOptions } from "./field_utils";
export declare class BaseFieldToggle extends Blockly.FieldNumber implements FieldCustom {
protected trueText: string;
protected falseText: string;
isFieldCustom_: boolean;
private params;
private state_;
private checkElement_;
private toggleThumb_;
CURSOR: string;
private type_;
constructor(state: string, params: FieldCustomOptions, trueText: string, falseText: string, opt_validator?: Blockly.FieldValidator);
initView(): void;
getDisplayText_(): string;
getTrueText(): string;
getFalseText(): string;
getFieldDescription(): string;
updateSize_(): void;
getInnerWidth(): number;
getMaxLength(): number;
getOutputShape(): number;
doClassValidation_(newBool: any): any;
applyColour(): void;
/**
* Return 'TRUE' if the toggle is ON, 'FALSE' otherwise.
* @return {string} Current state.
*/
getValue(): string;
/**
* Set the checkbox to be checked if newBool is 'TRUE' or true,
* unchecks otherwise.
* @param {string|boolean} newBool New state.
*/
doValueUpdate_(newBool: string): void;
switchToggle(newState: boolean): void;
render_(): void;
/**
* Toggle the state of the toggle.
* @private
*/
showEditor_(): void;
private toVal;
private fromVal;
}
export declare class FieldToggle extends BaseFieldToggle {
constructor(state: string, params: FieldCustomOptions, opt_validator?: Blockly.FieldValidator);
}