4D v13

Adding a Custom Menu Bar

Home

 
4D v13
Adding a Custom Menu Bar

Adding a Custom Menu Bar  


 

 

In this section, you will design two methods and a custom menu bar. In short, you are going to create a custom 4D application.

1. Select New > Method.. from the File menu.

The New Method dialog box appears.

2. Enter “M_ADD_RECORDS” in the New Method dialog box, then click OK.

A method editor window appears titled “Method:M_ADD_RECORDS”.

3. Enter the code of the M_ADD_RECORDS method as shown:

4. Create a second method named “M_LIST_RECORDS” with the following code:

Now that the two methods have been created, you will create a custom menu bar and attach the methods to custom menu commands.

1. Select Tool Box > Menus from the Design menu.

The Menu Bar Editor appears containing a default menu bar.

2. Select the title "Menu Bar # 1" and click the add button in the central part of the window.

3. Enter “Tutorial” as the menu title and press Enter.

4. Right click on the title “Tutorial” and choose Add an item to menu "Tutorial":

5. Enter “Add Records...” and press Enter.

6. Right click on the title “Tutorial” again to add a second menu command to the“Tutorial” menu.

7. Enter “Queries...” and press Enter.

The menu bar #1 should look like this:

8. Click the “Add Records...” menu command and select “M_ADD_RECORDS” in the Method Name combo box.

9. Click the “Queries...” menu command and select “M_LIST_RECORDS” in the Method Name combo box.

The menu bar #1 should now look like this:

10. Close the Tool box window.

You're done!

11. Select Test Application from the Run menu.

You are now using your application with the menus you just designed:

For example, if you select Queries... from the Tutorial menu, the standard 4D Query editor appears. You can define your query, then display and modify the records found by the query.

The interesting point is that, without knowing it, you just developed two applications!

To see why, go to the section Working Concurrently with 4D Server.

 
PROPERTIES 

Product: 4D
Theme: 4D Server in 10 minutes