Menu.menu
Menu widget.
A menu inherits from Pack.box
to arrange its items. Regular menus have vertical orientation (i.e. items are packed vertically, but horizontal orientation is supported.
inherit Stk.Pack.box
Close the menu window if it exists (i.e. if menu is displayed). This also closes windows attached to the submenus of its items.
Create a new window to display the menu. Optional parameters:
x
and y
for top-left coordoninates of the window. Default is to use mouse position.on_close
specifies a function to be called when the menu is closed. Argument indicates if the menu is the last still displayed.method add_item : ?pos:int -> menuitem -> unit
Menu items must be added using this method rather than (inherited) #pack
. pos
can be used to specify the 0-based position of the item among items already present. Default is to insert after all existing items.
method append_item : menuitem -> unit
Same as menu
.add_item but insert item as last item.
method prepend_item : menuitem -> unit
Same as menu
.add_item but insert item as first item.
method remove_item : menuitem -> unit
Menu items must be removed using this method rather than (inherited) #unpack
.