When the solution matters

Tips...

Registration Documentation Knowledgebase Seminars / Training Technical Support Partner Central

Step 13) Custom Menus

Prerequisites

Introduction

A custom application is a database designed to fill a specific need. It has a user interface designed specifically to facilitate its use. The tasks that an application performs are limited to those appropriate for its purpose. Creating applications with 4th Dimension is smoother and easier than with traditional programming. 4th Dimension can be used to create a variety of applications, including:

It is possible that a single application could even contain all of these systems. Applications like these are typical uses of databases. In addition, the tools in 4th Dimension allow you to create innovative applications, such as:

An application typically starts as a database used in the User environment. The database "evolves" into an application as it is customised. What differentiates a custom application is that the systems required to manage the database are hidden from the user. Database management is automated, and users use a custom interface to perform specific tasks.

When you use a 4th Dimension database in the User environment, you must know the steps to take to achieve a result. In a custom application, you use the Custom Menus environment, in which you need to manage all the aspects that are automatic in the User Environment. These include:

As you use a database, you perform some sequences of tasks repeatedly. For example, in a database of personal contacts, you might search for your business associates, order them by last name, and print a specific report each time information about them is changed. These tasks may not seem difficult, but they can certainly be time-consuming after you have done them 20 times. In addition, if you don't use the database for a couple of weeks, you may return to find that the steps used to generate the report are not so fresh in your mind. The steps in methods are chained together, so a single command automatically performs all the tasks linked to it. Consequently, you do not have to worry about the specific steps.

Applications have custom menus and perform tasks that are specific to the needs of the person using your database. An application is composed of all the pieces of your database: the structure, the forms, the object, form and project methods, the menus, and the passwords.

You can compile your databases and create stand-alone Windows and Macintosh applications. Compiling databases increases the execution speed of the language, protects your databases, and allows you to create applications that are completely independent. The integrated compiler also checks the syntax and the types of variables in methods for consistency.

An application can be as simple as a single menu that lets you enter people's names and print a report, or as complex as an invoicing, inventory, and control system. There are no limits to the uses of database applications. Typically, an application grows from a database used in the User environment to a database controlled completely by custom menus.

Creating Custom Menus

You can create custom menus for your databases and custom applications. Because pull-down menus are a standard feature of any desktop application, their addition will make you databases easier to use and will make them feel more familiar to users. When you create custom menus, you can also create custom toolbars. With custom menus and toolbars, your databases will perform more like "stand-alone" applications.

Creating custom menus is very simple—you associate methods or automatic actions with each menu command (also called menu items) in the Menu editor.

4th Dimension's Menu Bar Editor

User defined Project Methods are associated with menu items, and are invoked when the user selects the corresponding menu item in the Custom Menu environment.

menu bar editor screen shot

When the viewed from the Custom Menu environment, the following interface will appear:

custom menu login screen screen shot

Selecting a menu item will automatically execute the associated Project method. In this case, the following Project method, New person:

project method screen shot

For a complete walkthrough of this example, see A User's Perspective.

Important Concepts

4th Dimension allows you to create entire menu bars. A menu bar is the collection of menus that appears at the top of your application window. The menu bar displays the menu titles and the menus pull down to display the menu commands. Every menu item should be associated with a project method. Selecting an item from a menu in the Custom menu environment is the starting point for any user-invoked operation in a custom application.

Menu bars

A menu bar is a group of menus that can be displayed on a screen at the same time. Each menu on a menu bar can have many menu commands in it, including the File and Edit menus. You can create as many menu bars as you like.

Automatic Actions

Just as buttons and other interface objects can have automatic actions associated with them, so too can menu items. Actions can be overridden with your own project methods, so you can create special behavior for any menu item, specific to the task at hand.

The list of automatic actions for menus is listed here:

For more information on automatic actions for menu items, see 4D 2003 Upgrade Guide, Menu management, pages 20 – 26.

Additionally, existing automatic actions normally used for form objects may also be used with menu items:

For more info on Button Actions, see the 4D Design Reference, p. 383.

Default Menu Bar

4th Dimension 2003 automatically creates the first menu bar in every new database. It includes three menus: File, Edit and Use.

The current menu bar

The current menu bar is the menu bar that is currently displayed. Though you may have many menu bars defined, only one menu bar is displayed in a single process. (Different processes can have different current menu bars.)

The active menu bar

Once a menu bar is displayed as the current menu bar, it must be made active for its menus to work. Menu bar activation is controlled by the form that is currently displayed.

The splash screen

You can embellish each menu bar with a "splash screen," a custom graphic displayed in the default window of the Custom Menu environment.

More information about the splash screen can be found in the 4D Design Reference, p. 541.

Connected menus

When you write a custom application, you will usually find that you reuse certain menus in several places in your application. The same menu may be attached to several menu bars.

If you create a menu from scratch each time you use it in a menu bar, you must manage each menu separately, on a menu bar by menu bar basis. If you want to change a menu (disable or enable a menu command, place a check mark next to a menu command, and so on), you must change it every place that it occurs.

If you take advantage of the concept of "instances" of a menu by creating connected menus, managing menus becomes much easier. With connected menus, it is possible to update a menu wherever it occurs in a single step.

More information about connected menus can be found in the 4D Design Reference, p. 541.

For a complete discussion of creating custom menus including all of the above topics, see the 4D Design Reference page 529.

Additional information about changes since 4th Dimension 2003, see 4D 2003 Upgrade Manual, Chapter 2, Menu management, pages 20 – 26.

Compiler and Application Builder

4th Dimension 2003 applications include compilation functions that were previously available using the 4D Compiler application. Database compilation and compiled code testing can now be performed without quitting the 4th Dimension application.
To round out this feature, you can now build compiled databases (merged with 4D Engine or not) directly from 4th Dimension.

More information about Compiling and Building your application can be found in the 4D 2003 Upgrade manual, p. 81.

Learning Resources

4D Design Reference
Chapter 8 (Creating Custom Menus) pages 529 – 552.
Detailed discussion about designing, and creating menus, assigning methods to menu commands, connected menus, font styles in menus, enabling and disabling menus, previewing menus and adding a splash screen, menus and custom applications.

4D 2003 Upgrade Guide
Chapter 2 (Design Mode) pages 20 – 26
Discussion about the changes to the Menu Bar editor in 4th Dimension 2003.

Managing Menus
Language reference discussion about menu bars, including reference to the commands in the 4D language for managing menu bars.

Tech Tip: Preventing users from getting out of Custom Menus mode
Discusses several techniques for preventing users from switching out of the Custom Menus mode.


International | Company | Contact 4D | Site Map | Privacy Policy | © 4D UK 1995-2008 | Change font size: [A] [A] [A] | Print this page