Module | TkMenuSpec
In: | tk/lib/tk/menuspec.rb

tk/menuspec.rb

                                 Hidethoshi NAGAI (nagai@ai.kyutech.ac.jp)

based on tkmenubar.rb :

      Copyright (C) 1998 maeda shugo. All rights reserved.
      This file can be distributed under the terms of the Ruby.

The format of the menu_spec is:

      [ menu_info, menu_info, ... ]

And the format of the menu_info is:

      [
        [text, underline, configs], # menu button/entry (*1)
        [label, command, underline, accelerator, configs],   # command entry
        [label, TkVar_obj, underline, accelerator, configs], # checkbutton entry
        [label, [TkVar_obj, value],
                           underline, accelerator, configs], # radiobutton entry
        [label, [[...menu_info...], [...menu_info...], ...],
                           underline, accelerator, configs], # cascade entry (*2)
        '---', # separator
        ...
      ]

underline, accelerator, and configs are optional pearameters. Hashes are OK instead of Arrays. Then the entry type (‘command’, ‘checkbutton’, ‘radiobutton’ or ‘cascade’) is given by ‘type’ key (e.g. :type=>’cascade’). When type is ‘cascade’, an array of menu_info is acceptable for ‘menu’ key (then, create sub-menu).

NOTE: (*1)

      If you want to make special menus (*.help for UNIX, *.system for Win,
      and *.apple for Mac), append 'menu_name'=>name (name is 'help' for UNIX,
      'system' for Win, and 'apple' for Mac) option to the configs hash of
      menu button/entry information.

NOTE: (*2)

      If you want to configure a cascade menu, add :menu_config=>{...configs..}
      to the configs of the cascade entry.

[Validate]