Next: , Previous: , Up: Menu Library   [Contents][Index]


4.14.2 Menu Driver: The work horse of the menu system

As you have seen in the above example, menu-driver plays an important role in updating the menu. It is very important to understand various options it takes and what they do. As explained above, the second parameter to menu-driver can be either a navigational request, a printable character or a KEY_MOUSE key. Let’s dissect the different navigational requests.

REQ_LEFT_ITEM and REQ_RIGHT_ITEM

A menu can be displayed with multiple columns for more than one item. This can be done by using the menu-format function. When a multicolumnar menu is displayed these requests cause the menu driver to move the current selection to left or right.

REQ_UP_ITEM and REQ_DOWN_ITEM

These two options you have seen in the above example. These options when given, makes the menu-driver to move the current selection to an item up or down.

REQ_SCR_* options

The four options REQ_SCR_ULINE, REQ_SCR_DLINE, REQ_SCR_DPAGE, REQ_SCR_UPAGE are related to scrolling. If all the items in the menu cannot be displayed in the menu sub window, then the menu is scrollable. These requests can be given to the menu-driver to do the scrolling either one line up, down or one page down or up respectively.

REQ_FIRST_ITEM, REQ_LAST_ITEM, REQ_NEXT_ITEM and REQ_PREV_ITEM

Easy enough.

REQ_TOGGLE_ITEM

This request when given, toggles the present selection. This option is to be used only in a multivalued menu. So to use this request the option O_ONEVALUE must be off. This option can be made off or on with set_menu_opts.

Pattern Requests

Every menu has an associated pattern buffer, which is used to find the nearest match to the ASCII characters entered by the user. Whenever ASCII characters are given to menu_driver, it puts in to the pattern buffer. It also tries to find the nearest match to the pattern in the items list and moves current selection to that item. The request REQ_CLEAR_PATTERN clears the pattern buffer. The request REQ_BACK_PATTERN deletes the previous character in the pattern buffer. In case the pattern matches more than one item then the matched items can be cycled through REQ_NEXT_MATCH and REQ_PREV_MATCH which move the current selection to the next and previous matches respectively.

Mouse Requests

In case of KEY_MOUSE requests, according to the mouse position an action is taken accordingly. The action to be taken is explained in the man page as, If the second argument is the KEY_MOUSE special key, the associated mouse event is translated into one of the above pre-defined requests. Currently only clicks in the user window (e.g. inside the menu display area or the decoration window) are handled. If you click above the display region of the menu, a REQ_SCR_ULINE is generated, if you doubleclick a REQ_SCR_UPAGE is generated and if you tripleclick a REQ_FIRST_ITEM is generated. If you click below the display region of the menu, a REQ_SCR_DLINE is generated, if you doubleclick a REQ_SCR_DPAGE is generated and if you tripleclick a REQ_LAST_ITEM is generated. If you click at an item inside the display area of the menu, the menu cursor is positioned to that item.

Each of the above requests will be explained in the following lines with several examples whenever appropriate.


Next: , Previous: , Up: Menu Library   [Contents][Index]