DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
ETI menus

Fetching and changing the current item

The current item is the item where your end-user is positioned on the screen. Unless it is invisible, this item is highlighted and the cursor rests on the item. To have your application program set or determine the current item, you use the following functions.

SYNOPSIS

   int set_current_item (menu, item)
   MENU * menu;
   ITEM * item;
   

ITEM * current_item (menu) MENU * menu;

int item_index (item) ITEM * item;

Function set_current_item enables you to set the current item by passing an item pointer, while function current_item returns the pointer to the current item.

The function item_index takes an item pointer argument and returns the index to that item in the item pointer array. The value of this index ranges from 0 through N-1, where N is the total number of items connected to the menu.

Because the menu driver satisfies ETI-defined item navigation requests automatically, your application program need not call set_current_item, unless you want to implement additional item navigation requests for your application. You may, for instance, want a request to jump to a particular item or an item, say, two items down from the current one on the menu page.

When a menu is created by new_menu or the items associated with a menu are changed by set_menu_items, the current item is set to the first item of the menu.

As an example of set_current_item, the following function sets the current item of menu m to the first item of the menu:

   int set_first_item (m) /* set current item to first
       item */
   MENU *  m;
   {
   	ITEM ** i = menu_items (m);
   	return set_current_item (m, i[0]);
   }

As an example of current_item, the following routine checks if the first menu item is the current one:

   int first_item (m)  /* check if current item is first
       item */
   MENU * m;
   {
   	ITEM * i = current_item (m);
   	return item_index (i) == 0;
   }
If successful, function set_current_item returns E_OK. If an error occurs, function set_current_item returns one of the following:

E_SYSTEM_ERROR
system error

E_BAD_ARGUMENT
NULL menu pointer or item not connected to menu

E_BAD_STATE
called from initialization or termination routines
Function current_item returns (ITEM *) 0 if given a NULL menu pointer or there are no items connected to the menu.

Function item_index returns -1 if the item pointer is NULL or the item is not connected to a menu.


Next topic: Fetching and changing the top row
Previous topic: Using an initialization routine to generate item prompts

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