Programming Guide



sm_menu_change

Sets a menu's properties

int sm_menu_change(int mem_location, char *script, char *menu, int prop, int intval, char *strval);

mem_location
The menu's memory location, one of these constants:
MNL_ANY
MNL_APPLIC
MNL_SCREEN
MNL_FIELD

If set to MNL_ANY, Panther looks for the menu in all memory locations. If the menu is installed in more than one location, the call fails and returns MN_ERR_LOCATION.

script
The name of a memory-resident script that contains the menu to change. The script must already be loaded into memory at mem_location by sm_mnscript_load. If you supply NULL, Panther searches among the most recently loaded script in mem_location for the specified menu.

menu
The menu to change. If set to NULL, Panther uses the first menu in script.

prop
The property to change. Table 5-11 lists properties that you can change and their constants.

intval
The integer value to set for prop. Supply 0 if prop takes a string value.

strval
The string value to set for prop. Supply NULL if prop takes an integer value.

Environment

C only

Returns

Description

sm_menu_change sets a menu property. Menu properties are derived from a memory-resident script. Because sm_menu_change changes the specified script, all instances of menus from this script get the requested property change.

Specify the property to change through one of the constants in Table 5-11. Menu-specific properties begin with a prefix of MN. Properties that begin with MNI set defaults for new items that are added to the menu at runtime. If you call sm_menu_change to reset item property defaults, the changes only affect items that are added after this call; it leaves existing menu items unchanged. To reset item properties for individual items, call sm_mnitem_change.

Table 5-11 Menu properties that can be changed at runtime

Property Type* Description

MN_EXTERNAL

int

A value of PROP_ON or PROP_OFF specifies whether to find this menu's definition in another script.

MN_NAME

str

The name of this menu. The function does not check for duplicate names.

MN_TEAR

int

A value of PROP_ON or PROP_OFF enables or disables this submenu as a tear-off menu.

MN_TITLE

str

A title to display with popup menus.

MNI_ACCEL_ACTIVE

int

A value of PROP_ON or PROP_OFF specifies whether menu item accelerators are active.

MNI_ACTIVE

int

A value of PROP_ON or PROP_OFF allows or disallows access to menu items. If MNI_ACTIVE is set to PROP_OFF, menu items are greyed out.

MNI_INDICATOR

int

A value of PROP_ON or PROP_OFF specifies whether to show the toggle indicator on items.

MNI_SEP_STYLE

int

The default style used by separator-type items, specified by one of these integer constants:

SEP_SINGLE
SEP_DOUBLE
SEP_NOLINE
SEP_SINGLE_DASHED
SEP_DOUBLE_DASHED
SEP_ETCHEDIN
SEP_ETCHEDOUT
SEP_ETCHEDIN_DASHED
SEP_ETCHEDOUT_DASHED
SEP_MENUBREAK
SEP_TYPE_MASK

MNI_SHOW_ACCEL

int

A value of PROP_ON or PROP_OFF specifies whether menu items display the accelerator key next to their labels.

* For integer-type properties, supply an argument for the intval parameter and set the strval parameter to NULL; for string-properties, supply an argument for the strval parameter and set the intval parameter to 0.

Example

/*enable and disable menu tear-offs*/

int ToggleTearOffs(void)
{
int errorCode;
switch
(sm_menu_get_int(MNL_SCREEN, "menucom", "main", MN_TEAR)
{
/*enable tear-offs */
case 0: sm_menu_change
(MNL_SCREEN, "menucom", "main", MN_TEAR, 1, NULL);
break;

/*disable tear-offs */
case 1: sm_menu_change
(MNL_SCREEN, "menucom", "main", MN_TEAR, 0, NULL);
break;

/* if error returned, find out why */
case -1:
errorCode = sm_menu_bar_error();
menuErrorHandler(errorCode);
break;
}
}

See Also

sm_mnitem_change