Module: TkMenuSpec
- Extended by:
- TkMenuSpec
- Included in:
- Tk::Itk::Toplevel, Tk::Menu, Tk::Root, Tk::Toplevel, TkMenuSpec, TkMenubar
- Defined in:
- lib/tk/menuspec.rb
Overview
frozen_string_literal: false
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:
[ menubutton_info, menubutton_info, ... ]
The format of the menubutton_info is:
[ menubutton_info, entry_info, entry_info, ... ]
And each format of *_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
...
]
A menu_info is an array of menu entries:
[ entry_info, entry_info, ... ]
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).
If the value of underline is true instead of an integer, check whether the text/label string contains a ‘&’ character. When includes, the first ‘&’ is removed and its following character is converted the corresponding ‘underline’ option (first ‘&’ is removed). Else if the value of underline is a String or a Regexp, use the result of label.index(underline) as the index of underline (don’t remove matched substring).
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.
Constant Summary collapse
- MENUSPEC_OPTKEYS =
[ 'layout_proc' ]