package stk

  1. Overview
  2. Docs

Menus and menubars.

type item_menu_state =
  1. | Folded
  2. | Unfolded

A menu item with a menu attached can be either Folded or Unfolded.

val item_menu_state_wrapper : item_menu_state Ocf.Wrapper.t
val item_menu_state : item_menu_state Props.prop

Property "item_menu_state" for menu state. Default is Folded.

val shortcut : Key.keystate Props.prop

Keyboard "shortcut" property for a menu.

class menuitem : ?class_:string option -> ?name:string option -> ?props:Props.t option -> unit -> object ... end

An entry in a menu. The child of the entry is displayed in the menu. A (sub)menu can be attached to the item. In this case, when the item is unfolded, its attached menu is displayed.

class menu : ?class_:string option -> ?name:string option -> ?orientation:Props.orientation option -> ?props: Props.t option -> unit -> object ... end

Menu widget.

class menubar : ?class_:string option -> ?name:string option -> ?orientation:Props.orientation option -> ?props: Props.t option -> unit -> object ... end

Menubar widget.

val menubar : ?class_:string -> ?name:string -> ?orientation:Props.orientation -> ?props:Props.t -> ?pack:(Widget.widget -> unit) -> unit -> menubar

Convenient function to create a menubar. Optional argument orientation defines vertical or horizontal orientation; default is Horizontal. See widget_arguments for other arguments.

val menuitem : ?class_:string -> ?name:string -> ?props:Props.t -> ?shortcut:Key.keystate -> ?pack:(menuitem -> unit) -> unit -> menuitem

Convenient function to create a menuitem. Optional argument shortcut defines keyboard shortcut. See widget_arguments for other arguments.

val label_menuitem : ?class_:string -> ?name:string -> ?props:Props.t -> ?text:string -> ?shortcut:Key.keystate -> ?pack:(menuitem -> unit) -> unit -> menuitem * Text.label

Convenient function to create a menuitem with a horizontal Pack.box child. Two label widgets are added to the box. The first one is the label of the item (with initial text if provided). Optional argument shortcut defines keyboard shortcut and it is displayed in the second label (which has class_ "menuitem_shortcut"). See widget_arguments for other arguments. The function returns the menu item and the first label (the one for the menu item text).

val menu : ?class_:string -> ?name:string -> ?props:Props.t -> ?pack:(menu -> unit) -> unit -> menu

Convenient function to create a menu. Optional argument orientation defines vertical or horizontal orientation; default is Vertical. See widget_arguments for other arguments.

Utilities for popup menus

type menu_entry = [
  1. | `I of string * (unit -> unit)
  2. | `C of string * bool * (bool -> unit)
  3. | `R of (string * bool * (bool -> unit)) list
  4. | `M of string * menu_entry list
]

Menu entry description:

  • `I (text, cb) is a label item with text, and cb is called when item is activated.
  • `C (text, init, cb) is a checkbox item with text; init indicates whether the box is checked and cb is called with state when item is activated.
  • `R [(text1, init1, cb1) ; ...] is same as `C but describes a list of radiobuttons.
  • `M (text, entries) describes a submenu with text for the menu item and a list of entries.
val popup_menu_entries : [< `C of 'b | `I of string * (unit -> unit) | `M of string * 'a | `R of 'c ] list as 'a -> unit

popup_menu_entries entries create a menu according to the entries description and pops it up. The menu is closed when an item is activated (or an event occurs closing menu windows). This function is typically used for contextual menus.

OCaml

Innovation. Community. Security.