AcornSearch - Acorn and RISC OS information searching
RISC OS Search
containing
"Nutty quip goes here!"
Home  |  About  |  Filebase Archive  |  StrongHelp Manuals  |  Newsgroups  |  Module Database
Decodes menu after user selection.

*     R0 =     menu handle or zero if current menu
     R1 ®     to the list of menu selections
*     R0 ®     item handler or zero
     R1 =     TRUE if selection was made with ADJUST. [undocumented, but used in !TemplEd]
     R2 ®     block [original docs said this was returned in R1 - this appears to be incorrect!]

Use:     Block pointed to by R1 must contain the list of menu selections in the same format as returned by Wimp_Poll in case of menu selection event.

     This call maps the list of menu selections onto menu data structure and determines corresponding menu items. Various information about last two items from this list (selected item and parent item from menu one level up if any) is written into special block. A pointer to this block is returned in R2.

     If the item has been selected from the top-level menu then there will be no parent item and corresponding part of the block will be filled with zeros.

     If during creation of this item you have specified the handler then R0 on exit will contain the pointer to this handler otherwise R0 will be zero. Interpretation of item handler is determined by initialisation type (see MenuUtil_Initialise). If initialisation type was "BASIC" then R0 will point to ctrl-terminated text string. If initialisation type was "machine code" (notsupported by current version) then R0 will contain the value passed in R2 to MenuUtil_Add. To invoke BASIC handler you can use EVAL statement.

Example code...
Example code (MenuUtil_Decode)
Suppose Wimp_Poll has returned reason code 9 (Menu_Selection) and q% points to the corresponding block. You can use MenuUtil_Decode to call the item handler in the following way:

SYS "MenuUtil_Decode",,q% TO handler%
IF handler% THEN
handler$="FN"+$handler%
IF EVAL(handler$)
ENDIF
Format of Block at R2 on exit
Format of the returned block is as follows:
+0     position of selected menu item in menu (starting from 0)
+4     pointer to selected item data
+8     selected item handle or zero if item was created without MenuUtils
+12     pointer to text string of selected item
+16     position of parent menu item in menu (starting from 0)
+20     pointer to parent item data
+24     parent item handle or zero if item was created without MenuUtils
+28     pointer to text string of parent item

[sh-index] Back to list of manuals