This is kind of lite version of DynamicComponents extension, it create and return an component directly, you may save it to a variable, or into a list or a dictionary for later use.
Thanks for yusufcihan’s wonderful work, which inspired my a lot.
UPDATE HISTORY
v8 updatd:
Helper blocks added for component and property socket,
Now NO NEED to type the component name or property name, just select from the dropdown list:
ONLY USE THIS IN NEW PROJECT, THIS MAY DAMAGE YOUR PROJECT USING PREVIOUS VERSION.
v7.1
bug fixed (can not remove Sprite and Ball from Canvas)
Thanks for @sky.s.billow and @TIMAI2 for reporting this bug.
v7
Add OnClick and OffClick methods
v6
- add Children method and Parent method
- parameter name change
v5:
- fix bug for set Color relevant property. (big Thanks for @TIMAI2 )
- add method of CreateFrom.
BLOCKS
Create:
Create a visible component in a container.
component: String or Component. component Class Name.
in: Component. where the new component to be created inside.
Remove
remove the component from screen. if it's a container component, all his children will be removed.
Children
return a list of component container's children.
This can be used for native component containers.
Parent
return parent (container) of a component
Set
set the property of one specific component.
component: the component to set property. Not a String.
property: String. it can be the following 3 type:
- any in-build property name. even some property only show in Design pannel.
- "index", this tag will set the showing order of the component in his container.
- other string. this will give the component a user-defined property.
value: String. value of the tag.
Get
get the property's value of a component.
CreateFrom
create a batch of components with template.
template: String. a json string descriping the structure of the components. (see below for how to get a template)
in : Component. where the new components to be created inside.
values: properties to replace the template.
HOW TO GET A TEMPLATE
a template is a json string like:
-
At designer panel, you drag and drop the component, and make the layout as you wish, set all necessary properties.
-
select the component (normally a container, but one single component is OK) in the Viewer or component tree, press Ctrl+C. (lools like this only work at MIT server, not Kodular)
-
go to Blocks panel, drag out a "empty string" block, and presse Ctrl+V to paste the template inside the block.
-
if we want to change the property in the template, replace the origin by {1}, {2}, {3}...
for example, we want to change the Text and TextColor, we can change the template like this:
-
feed the values socket with new property values
v7 update:
Add OnClick and OffClick methods
OnClick will bind a click event to a component like label, button, or even an arrangement.
This one have high priority than native event.