ETI menus

Setting item options

An option is an attribute whose value may be either on or off. The current release of ETI provides the item option O_SELECTABLE. (In the future, ETI may provide additional options.) Setting the O_SELECTABLE option lets your user select the item. By default, O_SELECTABLE is set for every item. Function set_item_opts lets you turn on or turn off this and any future options for an item, while item_opts lets you examine the option(s) set for a given item.


   int set_item_opts (item, opts)
   ITEM * item;
   OPTIONS opts;

OPTIONS item_opts (item) ITEM * item;


In addition to turning on the named item options, function set_item_opts turns off any other item options.

If successful, set_item_opts returns E_OK. Otherwise, it returns the following:

system error
If function set_item_opts is passed a NULL item pointer, like other functions it sets the new current default. If function item_opts is passed a NULL pointer, it returns the current default.

If you turn off option O_SELECTABLE, the item cannot be selected. You might want to make an item unselectable to emphasize certain things your application program is doing. Unselectable items are displayed using the grey display attribute, described in ``Fetching and changing a menu's display attributes''.

Because options are Boolean values (they are either on or off), you use C Boolean operators with item_opts to turn them on and off. Consequently, to turn off option O_SELECTABLE for item i0 and turn on the same option for item i1, you can write:

   ITEM * i0, * i1;

set_item_opts (i0, item_opts (i0) & ~O_SELECTABLE); /* turn option off */ set_item_opts (i1, item_opts (i1) | O_SELECTABLE); /* turn option on */

ETI also enables you to turn on and off specific item options without affecting others, if any. The following functions change only the options specified.


   int item_opts_on (item, opts)
   ITEM * item;
   OPTIONS opts;

int item_opts_off (item, opts) ITEM * item; OPTIONS opts;

These functions return the same error conditions as set_item_opts.

As an example, the following code turns option O_SELECTABLE off for item i0 and on for item i1.

   ITEM * i0, * i1;

item_opts_off (i0, O_SELECTABLE); /* turn option off */

item_opts_on (i1, O_SELECTABLE); /* turn option on */

To change the current default to not O_SELECTABLE, you can write either
   	/* set current defaults for all new items */

set_item_opts ((ITEM *) 0, item_opts( (ITEM *) 0) & ~O_SELECTABLE);

   item_opts_off ((ITEM *) 0, O_SELECTABLE);
   	/* turn default option off */

Next topic: Checking an item's visibility
Previous topic: Fetching item names and descriptions

© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 27 April 2004