+1

Create Tag Help

Gruckman 12 year бұрын updated by icahill (Administrator) 12 year бұрын 3
How do you make a create action that will make a panel every time it is pressed?
I want to make a button that will create a new panel every time it is pressed that has new attributes. Each panel needs to have its own actions as well.
+1
The create tag is used to build a class on the fly based on a triggered action. In your scenario you would need to create your panel(s) as a class with variable content. (see Classes Tutorial).

Then on your button you can add an onclickup to trigger an action that will create your class. A create tag essentially takes the place of the object tag when using classes.

Because you require that your created panels have different content, you may have to determine several different create tags and wrap them in a randomgroup tag within your action to allow for different panels to get created at random.


<wire>
<classes>
<class name="panel">
<panel name="[param:name]" width="100%" height="100%" onclickup="[param:action]"></panel>
</class>
</classes>

<main>
<panel name="button" width="40" height="40" background="ff0000" onclickup="create"></panel>
<panel name="container" alias="CONTAINER" width="90%" height="90%" valign="bottom"></panel>
</main>

<actions>
<action name="create">
<randomgroup>
<create class="panel" name="1" onclickup="action1" target="CONTAINER"/>
<create class="panel" name="2" onclickup="action2" target="CONTAINER"/>
<create class="panel" name="3" onclickup="action3" target="CONTAINER"/>
</randomgroup>
</action>
</actions>
</wire>
Is there a way to make the actions in a randomgroup tag happen in order for each time it is activated? Or is it possible to make the created panels float so that they do not overlap?
To perform action in chronological order, you would want to use a sync tag. This would perform everything in a single action trigger though. Randomgroup will only perform one per trigger.

If you don't want your panels to overlap, consider putting them into a pager when you create them, that way they will fall in line.