Sw4   >   Menus   >   Menus

Menus

This section covers topics releated to menus and navigation.

Main Menu

The main menu for your StudioWorks application is called mMainMenu. A subclass of mMainMenu is located in your main library. You can add as many menu lines to the main menu in your main library as you like. There are a number of developer only menu lines included in mMainMenu. These do not appear to the runtime users.

You can add an mProgrammer menu to any module in your StudioWorks app. Your mProgrammer menu(s) will be dynamically added to the mMainMenu as a cascading menu.

Main Window

The main window has the navigation treelist on the left side and the subwindows on the right side.

Shift+clicking on a navigation treelist node opens a new instance of the clicked node in a separate window.

Navigation List Editor

You add/remove reports menus to window instances using the Window Menus List Editor.

The Window Menus List Editor is on a tab of the Window Instances Browsertab of the Programmer Workbench.

The following example gives the steps to follow for adding the DatabaseTablesViewer window instance to the SysAdmin group of the navigation list.

  1. Go to the Navigation List Editor under a tab of the Window Instances Browser of the Programmer Workbench.
  2. Expand the System Administration root node.
  3. Right-click on the System Administration root node or one its child nodes, and select Add WinInstID... from the context menu.
  4. In the prompt window, expand the swGui4 node, then select the DatabaseTablesViewer window instance node, and click the Continue button. The DatabaseTablesViewer window instance will be added to the navigation list.
  5. Drag and drop the DatabaseTablesViewer window instance in the navigation list to the final location you want it to appear in the navigation list.

You add a group or subgroup by right-clicking on the treelist and selecting the appropriate context menu line. After adding the group or subgroup you will need to add window instances to it or drag and drop existing navigation menu lines onto the new group or subgroup. If you remove all of the menu lines from a group or subgroup the empty group or subgroup the group/subgroup will not appear in the main window navigation list.

You can drag and drop groups or subgroups to change their order in the navigation menu list.

The navigation menus list, groups list, and subgroups list are dynamcially updated and saved to the oModuleData object of the main library so you do not have to rebuild the menus list after making changes in the Navigation List Editor.

Commands Menus

The standard commands for StudioWorks is the mCommands menu. The following menu items are included in the menu.

  1. Save - Ctrl/Cmnd + S
  2. Save & Close - Ctrl/Cmnd + Shift + S
  3. Revert - Ctrl/Cmnd + R
  4. Cancel - Ctrl/Cmnd + L
  5. Edit - Ctrl/Cmnd + E
  6. New - Ctrl/Cmnd + N
  7. New Copy - Ctrl/Cmnd + Shift + N
  8. Delete - Ctrl/Cmnd + D
  9. Find - Ctrl/Cmnd + F - Opens the Find prompt window - List window only
  10. Find All - Ctrl/Cmnd + Shift + S - Fetches all records - List window only
  11. Print - Ctrl/Cmnd + P
  12. Enable/Disable Shortcut Keys - Toggle the shortcut keys - Developer only

The Commands menu items are always enabled. If the user select a commands menu line, the mCommands menu tests for a $doCmnd method in the $topwind. If the method exists it sends a $doCmnd message with the menu line name as the only parameter.

If the $topwind is a shell window it forwards the $doCmnd to the current subwindow. It is the responsibility of the subwindow to process or ignore the command. For example, the user might not actually be permitted to delete records, so the subwindow would ignore a $doCmnd('Delete') message. The standard StudioWorks subwindows have a list of active commands which determines whether a command is processed or ignored.

Reports Menus

You add/remove Reports menus to window instances using the Window Menus List Editor.

The Window Menus List Editor is on a tab of the Window Instances Browsertab of the Programmer Workbench.

The following example gives the steps to follow for adding a Reports menu to the UsrList window instance.

  1. Go to the Window Menus List Editor under a tab of the Window Instances Browser or the Programmer Workbench.
  2. Expand the System Administration root node.
  3. Right-click on the UsrEdit node and select Add Reports Menu... from the context menu.
  4. Enter ActiveUsers in the prompt and click the OK button.

    StudioWorks will add the Reports menu to the UsrList window instance with the Active Users menu line. At the same time, StudioWorks added a $ActiveUsers method to the oReportsMenuObserver object class of the library, and an $ActiveUsers method to the oPrintReport object class of the library. StudioWorks automatically adds the object classes if they didn't exist. StudioWorks also parsed ActiveUsers into Active Users and added it to the sMn_stb schema class of the library and updated the string tables cached list.

    You can click on the edit pencil beside the observer objectclassname field to go to the method. The oReportsMenuObserver is considered a visual class, meaning it can prompt the user for any input if needed.
  5. To add menu lines to an existing menu, right-click on the menu and select Add Menu Line...
  6. You can drag and drop menu lines to reorder them.
  7. To delete menu lines, select the menu lines, right-click on the menu line, and select Delete Menu Line...
  8. To delete a menu, right-click on the menu, and select Delete Menu...
  9. To edit existing menu lines, select the menu line, then modify the values in the entry fields.

The window menus list is dynamcially updated and saved to the oModuleData object of each menu lines' home library.

If you open the window instance, the menu and menu lines should appear. If you select the menu line, you should end up at a breakpoint in the observer class method.

Special Menus

You add/remove Special menus to window instances using the Window Menus List Editor.

The Window Menus List Editor is on a tab of the Window Instances Browsertab of the Programmer Workbench.

The add a Special menu to a window instance:

  1. Go to the Window Menus List Editor under a tab of the Window Instances Browser or the Programmer Workbench.
  2. Expand the treelist nodes till you get to the window instance you want to add the menu to.
  3. Right-click on the window instance and select Add Special Menu... from the context menu.
  4. Enter a menu line you wish to add tp the menu and click the OK button.

    StudioWorks will add the Special menu and menu line to the window instance. At the same time, StudioWorks adds a public method to the oSpecialMenuObserver object class of the library. StudioWorks automatically adds the object class if it didn't exist. StudioWorks also parses the menu line ID into words and adds it to the sMn_stb schema class of the library and updates the string tables cached list.

    You can click on the edit pencil beside the observer objectclassname field to go to the method. The oSpecialMenuObserver is considered a visual class, meaning it can prompt the user for any input if needed.
  5. To add menu lines to an existing menu, right-click on the menu and select Add Menu Line...
  6. You can drag and drop menu lines to reorder them.
  7. To delete menu lines, select the menu lines, right-click on the menu line, and select Delete Menu Line...
  8. To delete a menu, right-click on the menu, and select Delete Menu...
  9. To edit existing menu lines, select the menu line, then modify the values in the entry fields.

The window menus list is dynamcially updated and saved to the oModuleData object of each menu lines' home library.

If you open the window instance, the menu and menu lines should appear. If you select the menu line, you should end up at a breakpoint in the observer class method.

When a Special menu line is selected the applicable method in the oSpecialMenuObserver object class is called.

Other Menus

You add/remove Other menus to window instances using the Window Menus List Editor.

The Window Menus List Editor is on a tab of the Window Instances Browsertab of the Programmer Workbench.

The add an Other menu to a window instance:

  1. Go to the Window Menus List Editor under a tab of the Window Instances Browser or the Programmer Workbench.
  2. Expand the treelist nodes till you get to the window instance you want to add the menu to.
  3. Right-click on the window instance and select Add Other Menu... from the context menu.
  4. Enter a menu line you wish to add tp the menu and click the OK button.

    StudioWorks will add the Special menu and menu line to the window instance. At the same time, StudioWorks adds a public method to the OtherMenuObserver object class of the library. StudioWorks automatically adds the object class if it didn't exist. StudioWorks also parses the menu line ID into words and adds it to the sMn_stb schema class of the library and updates the string tables cached list.

    You can click on the edit pencil beside the observer objectclassname field to go to the method. The oOtherMenuObserver is considered a visual class, meaning it can prompt the user for any input if needed.
  5. To add menu lines to an existing menu, right-click on the menu and select Add Menu Line...
  6. You can drag and drop menu lines to reorder them.
  7. To delete menu lines, select the menu lines, right-click on the menu line, and select Delete Menu Line...
  8. To delete a menu, right-click on the menu, and select Delete Menu...
  9. To edit existing menu lines, select the menu line, then modify the values in the entry fields.

The window menus list is dynamcially updated and saved to the oModuleData object of each menu lines' home library.

If you open the window instance, the menu and menu lines should appear. If you select the menu line, you should end up at a breakpoint in the observer class method.

When a Other menu line is selected the applicable method in the oOtherMenuObserver object class is called.

Shortcut Keys

You can add shortcut key combinations to the Reports, Special, and Other menus.

To do so select the menu line in the Window Menus List Editor tab of the Window Instances Browsertab of the Programmer Workbench and enter the shortcut key combination in the shortcutkey-string entry field.

Ctrl/Cmnd+K = kControl+asc('K',1)

Shift+Ctrl/Cmnd+K = kShift+kControl+asc('K',1)

Context Menus

The $control method of wEdit_abstract and wList_abstract test for On evOpenContextMenu. The $event_evOpenContextMenu method is called when this event occurs. You can override $event_evOpenContextMenu and add menu lines to the context menu. Sample code is provided in the superclass method for doing this.

To add a context menu to a window field:

  1. Select the window field and set the $contextmenu property of the field to swGui4.mContext
  2. Add On evOpenContextMenu to the $event method of the field.
  3. Send message to add menu lines or spacers to the context menu instance.

    The following sample code adds MenuLine1, a spacer line, and MenuLine2

    On evOpenContextMenu

    Do pContextMenu.$addMenuLine($cobj,'MenuLine1')
    Do pContextMenu.$addSpacer()
    Do pContextMenu.$addMenuLine($cinst,'MenuLine2')



    The parameters for $addMenuLine are:
    1. prObserver - Reference to the instance which will be sent a message if the menu line is selected. $cobj send the message to a field method, $cinst sends the message to a window class method.
    2. pMenuLineID - The ID of the menu line. The ID is translated to the string tables text for the menu line ID in the Mn string table.

  4. Add the recipient method to the specified observer. ($cobj the field methods, $cinst the window class methods). The recipient method must be the menu line ID prefixed with the $ character.

  5. Add your custom code to the receipient method.

All going well with the user right-clicks on th field, an instance of mContext will be opened and the menu lines you specified will be added to the menu instance. If the user selects one of the menu lines, a $TheMenuLineID message will be sent to the specified observer.