pxt icon indicating copy to clipboard operation
pxt copied to clipboard

Multiple problems in TurnRatio Playground

Open OffByOne37 opened this issue 1 year ago • 4 comments

The Playground example for Range is wrong!

Problem 1: There is a typo, it should be //% turnRatio.shadow=turnRatioPicker with a big R instead of //% turnratio.shadow=turnRatioPicker

Problem 2: Min Max can't be specified here. I think the Problem is in the file field_turnratio

constructor(value_: any, params: FieldTurnRatioOptions, opt_validator?: Function) { super(String(value_), '-200', '200', '1', '10', 'TurnRatio', opt_validator); this.params = params; (this as any).sliderColor_ = '#a8aaa8'; }

It looks like the min max values are preset with -200 and 200.

OffByOne37 avatar Sep 08 '23 14:09 OffByOne37

@OffByOne37 feel free to do a PR if you want. @kimprice take a peek?

abchatra avatar Sep 08 '23 15:09 abchatra

Yeah made a PR for the typo.

Looked a bit more on the second error but do not have enough time to thouroughly check it. But it seems like there is the need to add this

export interface FieldTurnRatioOptions extends Blockly.FieldCustomOptions { min?: number; max?: number; }

and /** * Class for a color wheel field. * @param {number|string} value The initial content of the field. * @param {Function=} opt_validator An optional function that is called * to validate any constraints on what the user entered. Takes the new * text as an argument and returns either the accepted text, a replacement * text, or null to abort the change. * @extends {Blockly.FieldNumber} * @constructor */ constructor( value_: any, params: FieldTurnRatioOptions, opt_validator?: Function ) { super( String(value_), params.min, params.max, "1", "10", "TurnRatio", opt_validator ); this.params = params; (this as any).sliderColor_ = "#a8aaa8"; }

But as I said, this is only an assumption from my side, and I would need to look further.

OffByOne37 avatar Sep 08 '23 16:09 OffByOne37

@OffByOne37 I checked your suggestion and unfortunately it does not solve the problem. We'll need to look into this further.

kimprice avatar Sep 15 '23 20:09 kimprice

Too bad, as I said it was only a guess, did not have enough time.

If I have time I will try again to find a solution.

OffByOne37 avatar Sep 18 '23 09:09 OffByOne37