One of the common requests we get from users is more customization for the title bar area with more flexibility e.g. placing a TextField for search or buttons in various ways. Chen recently took action on this by introducing the new Toolbar API that replicates some of the native functionality available on Android/iOS and integrates with features such as the side menu to provide very fine grained control over the title area behavior.
Everything that the toolbar allows was possible in the past with various customizations, the difference is that the Toolbar API makes such use cases much simpler. To get started we can set a Toolbar to a Form using myForm.setToolbar(toolbar).
At that point we can add commands to the side menu with most of the existing
side menu features
(such as SideComponent), however to add a command to the SideMenu we will need to use toolbar.
addCommandToSideMenu() instead of the standard add command. We can add commands to 4 locations:
addCommandToSideMenu – adds to the sidemenu
addCommandToOverflowMenu – adds the command to an Android style … menu on the top right hand side
addCommandToRightBar – places the command on the right side of the title
addCommandToLeftBar – places the command on the left side of the title
Normally you can just set a title with a String but if you would want the component to be a text field or a multi line label you can use
setTitleComponent(Component) which allows you to install any component into the title area.
At this time the GUI builder doesn’t include toolbar specific functionality, depending on user requirements we might add this in the future.
Notice: This post was automatically converted using a script from an older blogging system. Some elements might not have come out as intended…. If that is the case please let us know via the comments section below.