4D v16.3Pop-up Menus/Drop-down Lists |
||
|
4D v16.3
Pop-up Menus/Drop-down Lists
Pop-up Menus/Drop-down Lists
Pop-up menus and drop-down lists are objects that allow the user to select from a list. You manage the items displayed in the pop-up menu using an array or a choice list. The names “Pop-up menu” and “Drop-down list” refer to the same objects; “Pop-up menu” is part of Mac OS terminology and “Drop-down list” is part of Windows. As the following example shows, the appearance of these objects differs slightly according to the platform: Windows An array is a list of values in memory that is referenced by the name of the array (see Arrays and Form Objects). A pop-up menu/drop-down list displays an array as a list of values when you click on it. You initialize pop-up menu/drop-down list objects by loading a list of values into an array. You can do this in several ways:
If you need to save the user’s choice into a field, you would use an assignment statement that runs after the record is accepted. The code might look like this: Case of In the Events section of the Property List window, you must select each event that you test for in your Case statement. Arrays always contain a finite number of items. The list of items is dynamic and can be changed by a method. Items in an array can be modified, sorted, and added to. For information about creating and using an array, refer to the Arrays chapter in the 4D Language Reference manual. If you want to use a pop-up menu/drop-down list to manage the values of a listed field or variable, 4D lets you reference the field or variable directly as the object's data source. This makes it easier to manage listed fields/variables. Note: If you use a hierarchical list, only the first level is displayed and can be selected. For example, in the case of a "Color" field that can only contain the values "White", "Blue", "Green" or "Red", it is now possible to create a list containing these values and associate it with a pop-up menu object that references the 4D "Color" field. 4D then automatically takes care of managing the input and display of the current value in the form. To associate a pop-up menu/drop-down list or a combo box with a field or variable, you can just enter the name of the field or variable directly in the Variable Name area of the object: When the form is executed, 4D automatically manages the pop-up menu or combo box during input or display: when a user chooses a value, it is saved in the field; this field value is shown in the pop-up menu when the form is displayed:
Note: It is not possible to combine this principle with using an array to initialize the object. If you enter a field name in the Variable Name area, then you must use a choice list. When you have associated a pop-up menu/drop-down list with a choice list and with a field, you can use the Save as Value/Reference option available in the "Data Source" theme of the Property List. This option lets you optimize the size of the data saved. For more information, refer to Save as Value or Reference. You can assign the Goto Page standard action to a pop-up menu/drop-down list (“Action” theme of the Property List). When this action is selected, 4D will automatically display the page of the form that corresponds to the number of the object that is selected in the drop-down list. For example, if the user selects the third item of the list, 4D will display the third page of the current form (if it exists).
|
PROPERTIES
Product: 4D
HISTORY
ARTICLE USAGE
4D Design Reference ( 4D v16) |