GUI Commands User GuideVersion 2.1 |
||
Automatic CreationNormally command groups are only created when you explicitly call The following example shows a main menu bar group and its children. Each child is specified to be automatically created when the main menu group is built: group!main-menu@members=file-menu, edit-menu, help-menu group!file-menu@face.text=_File group!file-menu@autoCreate=true group!file-menu@members=... group!edit-menu@face.text=_Edit group!edit-menu@autoCreate=true group!edit-menu@members=... group!help-menu@face.text=_Help group!help-menu@autoCreate=true group!edit-help@members=... To create this menu all we need to do is the following: // All our children are marked as autoCreate so // we only need to create the parent group. CommandGroup mainMenu = new CommandGroup("main-menu"); mainMenu.bind(...); If we had not specified autoCreate then we would need to programmatically create each of the child groups as follows: // Create the main group. CommandGroup mainMenu = new CommandGroup("main-menu"); mainMenu.bind(...); // if autoCreate=false then we'd need to manually // create all the children as follows new CommandGroup("file-menu").bind(...); new CommandGroup("edit-menu").bind(...); new CommandGroup("help-menu").bind(...); Specifying the ClassYou can control the class instantiated by setting the class property of the group. If
left unspecified a standard group!file-menu@face.text=_File group!file-menu@autoCreate=true group!file-menu@class=my.package.CustomGroup Auto Create Gotcha'sWhen automatically creating groups there are some issues to be aware of:
Mulitple instances of the same group can be troublesome if you need to perform any programmatic
modifications. In this case, only one instance will update and you'll end up confused. In general
you should avoid using When using
If you're unsure it's best to leave |
||