src/swipl-devel/packages/xpce/man/refmanual/md/menu.md

class menu {#class-menu}

A Menu is a dialog item that allows the user the select one or more values from a list. In its functionality it is similar to a list_browser object. However, a list_browser is meant to select from a dynamically generated list that may be large, while a menu is meant to select from a small number of alternatives that is generally static.

Class menu defines a large number of options that determine both the layout of the items, the feedback provided for the selected item, and whether or not one or more items may be selected at the same time. For convenience, there is a method called Menu ->kind that allows you to select some common configurations with a single message.

Message forwarding {#class-menu-message-forwarding}

If the toggled menu_item has <->message not equal to @default, this message is executed with:

| @receiver | The menu                            |
| @arg1     | The menu_item                       |
| @arg2     | New value of `menu_item <-selected` |
| @arg3     | Equivalent to @event                |

If the message of the menu_item is @default, the message associated with the menu is executed. The arguments are:

| @receiver | The menu                            |
| @arg1     | `menu_item <-value`                 |
| @arg2     | New value of `menu_item <-selected` |
| @arg3     | Equivalent to @event                |

If the toggled menu_item has <->message not equal to @default, this message is executed with:

| @receiver | The menu             |
| @arg1     | `menu_item <-value`  |
| @arg2     | Equivalent to @event |

If the message of the menu_item is @default, the message associated with the menu is executed. The arguments are:

| @receiver | The menu             |
| @arg1     | The <-selection      |
| @arg2     | Equivalent to @event |

Menu layout {#class-menu-menu-layout}

A menu consists of a label and a list of items. The label is placed in a box described by the area Menu <-label_area. The items are placed in a two-dimensional array, each in its own box. These item boxes all have the same size (Menu <-item_size). The top-left-corner of the first item is at Menu <-item_offset.

If Menu <->layout equals horizontal, the items are placed left-to-right. If Menu <->layout equals vertical, the items are placed top-to-bottom. The items are spread over Menu <-columns columns. The following illustrates the placement of a menu with horizontal layout, 2 columns and 5 items:

label   item-1   item-2   item-3
        item-4   item-5

Various parameters influence the final layout. Menu<->gap defines the horizontal and vertical space between the items. Menu<->pen defines the thickness of the lines for the boxes drawn around the items. Menu<->border defines the white space between the item and the box around it.

@see menu->initialise @see menu_item-message @see menu-columns @see menu->kind @see dialog_item-auto_value_align @see class menu_item @see class popup

Instance variables {#class-menu-instvars}

Send methods {#class-menu-send}

Get methods {#class-menu-get}



Try the rswipl package in your browser

Any scripts or data that you put into this service are public.

rswipl documentation built on June 16, 2026, 5:07 p.m.