MenuItem

MenuItemNewB

Create a menu item that calls a block

Syntax

Signature
MenuItem     *MenuItemNewB( const char *caption, MenuItemBlock block, int shortcut, const char *message, int id );

Arguments

caption the menu text. & marks the following character as the accelerator. MENU_SEPARATOR creates a separator. NULL is invalid.

block a C function that receives the item when it is selected. A separator ignores this argument and accepts NULL.

shortcut the key code that activates the item, or NIL or 0 for no shortcut.

message the text shown when the item is current, or NULL for an empty string.

id the number that identifies the item, or NIL for 0.

Return value

The new MenuItem object, or NULL when caption is NULL or a regular item has a NULL block. Release it with MenuItemFree().

Description

Include xdev-wtui-classes.h. Use `MenuItemNewB()` for a callback and `MenuItemNewO()` for a submenu. The C constructors take separate types for the two values accepted by the xBase constructor. The callback receives the item and can read application data with `MenuItemGetCargo()`.

The constructor copies the caption and message. A regular item starts enabled and unchecked. A separator starts disabled and has no block.

See also