2014년 12월 12일 금요일

[App Inventor Open Source Development] Drop down for setting properties in Blocks Editor

I am working on the Lego Mindstorms EV3 support. The EV3 LED can only show 3 colors (RED, GREEN, ORANGE) and three patterns (STEADY, PULSE, FLASH).

I have figured out how to show a drop down menu for the colors/patterns in the designer. Is there a way to create drop-down menus in the blocks editor? Else the user will need specify pattern as a string and will only get a run-time error if she specifies a string different from the allowed ones.



this is an issue in several other cases too, for instance width and
height for elements and several other cases. It has been discussed
before, but I don't think there's a solution yet. It would be great to
come up with an standard way to do it, but for now, strings are being
used (with the problems you mentioned above).



A semi-kludgey way might be to just create another drawer in your Blocks Editor palette which contained an LED Color block and a Pattern block, each of which contained a FieldDropdown with the appropriate choices.

In the longer run we probably want to have a way to specify an enum type for components which would automatically create the Designer dropdowns and the Blocks Editor blocks for the component.



I could not figure out how to make a field drop down in the blocks editor. Is there an example of this?



If you search for FieldDropdown within the appinventor/blocklyeditor/src/blocks directory you'll find some.


댓글 없음:

댓글 쓰기