Applications: Foreground Applications
What are we learning here?
Application
components will be loaded by default into the levelforeground
Application components can be dragged only inside of the area of the stage in which it was loaded. Application components can be used to host complete applications or used for toolbox-windows or permanent displaying informations.
Applications will be loaded by default into the level foreground
. So they don't collide with other
components in the same stage loaded in other levels.
To demonstrate how to use application components in combination with other components, we have to do some preparations first.
(1) Extend our widget loading-components
that holds just a placeholder all the time (replace the
placeholder paragraph).
We extend the HTML structure and then we extend the component class.
- We add an option
target
to pass a compenent instance. If not set the stages of the parent component will be used to load components. - Implement a simple click handler logic which will take the function name from the attribute
data-role
. - Add two functions which will load our mockup application that we have already implemented into the
stage set into the main stage of
target
:
src/demo/components/loading-components/index.html
src/demo/components/loading-components/index.js
(2) Pass the option target
in some places we load the component loading-components
:
src/root.js
src/demo/apps/flexbox-component/index.js
You see the new buttons in three different places:
- In the header of the root component: Loading into the main stage of the root component.
- In the footer of the application component: Loading into the main stage of the application component.
- Inside the content area of the application component: Loading into the main stage of the widget
component
component-basic
.
Try all of them and drag the mockup application around to see the different areas in which the application can be dragged.
Furthermore one of the two buttons will use a fixed id to load the application:
×
loads an application without an and in this case every application (or any other component) will get a random id. You can start as many you want.✓
use the signaturethis.load(ComponentType, Id)
and load the application with an specific id. As we already know loading components with an already existing id will front them and not load them a second time. You can load only one application with this id.