Sub Menu Component
This class combines the configuration and the core rendering of a submenu inside a menu.
A submenu consists of different types of children that are aligned vertically. By default the following types can be added to the menu:
entries (see MenuEntry)
dividers (see MenuDivider)
It is also possible to add any other fritz2 component via the custom context. All menu items are created directly within the SubMenuComponent's build context.
Example usage:
menu {
entry {
icon { add }
text("Item")
}
divider()
submenu {
entry {
icon { add }
text("Item")
}
}
divider()
header("A subsection starts here")
custom {
// custom content
spinner { }
}
}The menu-entry-DSL can be extended via standard Kotlin extension methods. Custom entries must implement the Component<Unit> interface and are added to the Menu via the MenuComponent.addChild method which is accessible from within the extension method.
The following example adds an instance of MyMenuEntry to the Menu. Notice that addChild is invoked in the end; the entry wouldn't be added otherwise!
fun MenuComponent.example(build: MyMenuEntry.() -> Unit) = MyMenuEntry()
.apply(build)
.run(::addChild)