3
<META NAME="Author" CONTENT="Brent B. Welch">
4
<TITLE>MH & nmh: Resources for Menus</TITLE>
6
<!-- $Id: resmen.htm,v 6.0 1999/10/10 05:14:05 jpeek Exp $ -->
8
<BODY BGCOLOR="#FFFFFF">
10
<H1>Resources for Menus</H1>
11
[<A HREF="resbut.htm">previous</A>]
12
[<A HREF="butgro.htm">next</A>]
13
[<A HREF="tocs/jump.htm">table of contents</A>] [<A HREF="indexes/map.htm">index</A>]
16
The menus in <I>exmh</I> are defined similarly to buttons.
17
Naturally, menus are a little more complex than buttons -- but
18
the general idea is the same.
19
There are parallel sets of resources for the two parts of menus:
20
system-defined and user-defined.
21
Each section has a list of menus defined
22
with the <I>menulist</I> and <I>umenulist</I>.
23
Each menu, in turn, has a <I>text</I> resource that defines
24
the label on the menu button.
25
The <I>entrylist</I> and <I>uentrylist</I> resources list
26
the entries that are found under the menu.
27
Again, the system-defined entries are listed under <I>entrylist</I>;
28
users should add new entries to <I>uentrylist</I>.
30
Each menu entry has resources with the following naming
31
convention (this is not standard Tk).
32
If the entrylist item is <I>foo</I>, then:
35
l_<I>foo</I> defines the label (text) for the entry.
37
c_<I>foo</I> defines the command.
39
t_<I>foo</I> defines the type: "command", "check", "radio", "cascade", or
42
v_<I>foo</I> defines the variable associated with check and radio entries.
44
m_<I>foo</I> defines the menu associated with cascade entries.
46
To get more information, read the Tk
47
manual page for <I>menu</I>.
49
Here is an example -- the definition for the <I>exmh</I> main menus:
51
*Main.menulist: bind help
53
*Main.bind.text: Bindings...
54
*Main.bind.m.entrylist: command sedit
55
*Main.bind.m.l_command: Commands
56
*Main.bind.m.c_command: Bind_Pref
57
*Main.bind.m.l_sedit: Simple Edit
58
*Main.bind.m.c_sedit: Sedit_Pref
60
*Main.help.text: Help...
61
*Main.help.m.entrylist: help colorkey faq
62
*Main.help.m.l_colorkey: Color Legend
63
*Main.help.m.c_colorkey: Help_KeyDisplay
64
*Main.help.m.l_help: Quick Intro
65
*Main.help.m.c_help: Help
66
*Main.help.m.l_faq: Frequently Asked Questions
67
*Main.help.m.c_faq: Help FAQ
69
Note the additional <TT>.m</TT> component in the
70
<TT>*Main.help.m.entrylist</TT> resource name.
71
The <TT>*Main.help</TT> resource corresponds to the menu button, and
72
<TT>*Main.help.m</TT> corresponds to the menu associated with that button.
74
Here's another example.
76
the <I>uentrylist</I> resource to add a new menu entry to
77
the message <TT>More...</TT> menu.
78
It will be a check-button type of entry -- to set the Tcl
79
variable controlling the "skip marked" behavior of <TT>Next</TT> and
81
We'll also separate the user-defined entries from the
82
system entries with a special separator menu entry.
83
The resources in your <I>~/.exmh-defaults</I> file
84
would look something like this:
86
*Mops.more.m.uentrylist: sep skip
87
*Mops.more.m.t_sep: separator
88
*Mops.more.m.t_skip: check
89
*Mops.more.m.l_skip: Skip marked messages
90
*Mops.more.m.v_skip: ftoc(skipMarked)
92
In this case, the Tcl variable is <I>ftoc(skipMarked)</I>,
93
an element of an associative Tcl array.
94
Menu entries that use Tcl variables defined by <I>exmh</I>
95
might stop working in a future release.
96
However, you can easily get an idea of what the important
97
variables are by searching through the code for Preferences_Add
99
These calls set up the relationship between the internal Tcl
100
variables and the Preference items you see in the interface.
101
In most cases, the variables are elements of an associative array.
102
In the example above, <I>ftoc</I> is the array that holds the state variables
103
for <I>ftoc.tcl</I>, which implements the table of contents.
107
[<A HREF="tocs/jump.htm">Table of Contents</A>] [<A HREF="indexes/map.htm">Index</A>]
108
[<A HREF="resbut.htm">Previous: Resources for Buttons</A>]
109
[<A HREF="butgro.htm">Next: Button Groups</A>]
112
(This section was written by Brent Welch.)<BR>
113
<EM>Last change $Date: 1999/10/10 05:14:05 $</EM>
115
This file is from the third edition of the book <I>MH & xmh: Email
116
for Users & Programmers</I>, ISBN 1-56592-093-7, by Jerry Peek.
117
Copyright © 1991, 1992, 1995 by O'Reilly & Associates, Inc.
118
This file is freely available; you can redistribute it and/or modify
119
it under the terms of the GNU General Public License as published by
120
the Free Software Foundation. For more information, see
121
<A HREF="../copying.htm">the file <I>copying.htm</I></A>.
124
Suggestions are welcome:
125
<A HREF="http://www.beedub.com/exmh/">Brent Welch</A>
126
<A HREF="mailto:welch@acm.org"><welch@acm.org></A>