Example 1 – Tool Bar
This is best used for presenting functionality within a basic form, such as a maintenance form, as below.
There are 3 ways to define it: in the ‘.per’ file; dynamically in the code; or imported from XML:
- In the ‘.per’ file – to a large extent this will mean it is hard coded SCHEMA default
- Dynamically, in the code
In this example the ”text” attribute is not defined, so that value will be loaded from the action defaults file which has been specified.As in the code above, one can conditionally build the toolbar, so some users can be given more options than others, for instance. There is also functionality in Genero to disable/enable buttons, as below, so when the user is updating an order for instance, the buttons (or menu entries) for producing reports related to that order can be greyed out and then re-enabled when the update is complete.
- Imported from an XML file
Some users may have global permissions for the application, some may be allowed to update things but not create them, and others may only have ‘read’ permissions – one can have multiple versions of the toolbar file and load them depending on which user has logged in, for instance.
If there is already a tool bar defined in the form file, this action will not override it, but will simply add another tool bar to the window. In the screenshot below, the two buttons ‘Accept’ and ‘Cancel’ are defined in the form file, and the ‘Accounts’, ‘Orders’, ‘About’ and ‘Close’ buttons come from the file loaded using the statement as above.
However, if you load a second tool bar file, it will override that which was already loaded, but will leave that from the form file visible and usable. Also, if you import a tool bar and then use the code above to create items, they will be added to that which is already there, but the other way round will be an override.
Note – there is also a method ‘ui.Interface.loadToolBar’, but this will load a default for all forms subsequently opened.