]> ncurses.scripts.mit.edu Git - ncurses.git/blob - doc/html/man/menu_driver.3x.html
a2d67451301dd18b96a69a3b29756722be5238aa
[ncurses.git] / doc / html / man / menu_driver.3x.html
1 <!--
2   ****************************************************************************
3   * Copyright 2018-2020,2021 Thomas E. Dickey                                *
4   * Copyright 1998-2010,2017 Free Software Foundation, Inc.                  *
5   *                                                                          *
6   * Permission is hereby granted, free of charge, to any person obtaining a  *
7   * copy of this software and associated documentation files (the            *
8   * "Software"), to deal in the Software without restriction, including      *
9   * without limitation the rights to use, copy, modify, merge, publish,      *
10   * distribute, distribute with modifications, sublicense, and/or sell       *
11   * copies of the Software, and to permit persons to whom the Software is    *
12   * furnished to do so, subject to the following conditions:                 *
13   *                                                                          *
14   * The above copyright notice and this permission notice shall be included  *
15   * in all copies or substantial portions of the Software.                   *
16   *                                                                          *
17   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
18   * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
19   * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
20   * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
21   * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
22   * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
23   * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
24   *                                                                          *
25   * Except as contained in this notice, the name(s) of the above copyright   *
26   * holders shall not be used in advertising or otherwise to promote the     *
27   * sale, use or other dealings in this Software without prior written       *
28   * authorization.                                                           *
29   ****************************************************************************
30   * @Id: menu_driver.3x,v 1.30 2021/12/25 21:49:32 tom Exp @
31 -->
32 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
33 <HTML>
34 <HEAD>
35 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
36 <meta name="generator" content="Manpage converted by man2html - see https://invisible-island.net/scripts/readme.html#others_scripts">
37 <TITLE>menu_driver 3x</TITLE>
38 <link rel="author" href="mailto:bug-ncurses@gnu.org">
39
40 </HEAD>
41 <BODY>
42 <H1 class="no-header">menu_driver 3x</H1>
43 <PRE>
44 <STRONG><A HREF="menu_driver.3x.html">menu_driver(3x)</A></STRONG>                                                <STRONG><A HREF="menu_driver.3x.html">menu_driver(3x)</A></STRONG>
45
46
47
48
49 </PRE><H2><a name="h2-NAME">NAME</a></H2><PRE>
50        <STRONG>menu_driver</STRONG> - command-processing loop of the menu system
51
52
53 </PRE><H2><a name="h2-SYNOPSIS">SYNOPSIS</a></H2><PRE>
54        <STRONG>#include</STRONG> <STRONG>&lt;menu.h&gt;</STRONG>
55
56        <STRONG>int</STRONG> <STRONG>menu_driver(MENU</STRONG> <STRONG>*</STRONG><EM>menu</EM><STRONG>,</STRONG> <STRONG>int</STRONG> <EM>c</EM><STRONG>);</STRONG>
57
58
59 </PRE><H2><a name="h2-DESCRIPTION">DESCRIPTION</a></H2><PRE>
60        Once a menu has been posted (displayed), you should funnel input events
61        to it through <STRONG>menu_driver</STRONG>.  This routine has three major input cases:
62
63        <STRONG>o</STRONG>   The input is a form navigation request.  Navigation  request  codes
64            are constants defined in <STRONG>&lt;form.h&gt;</STRONG>, which are distinct from the key-
65            and character codes returned by <STRONG><A HREF="curs_getch.3x.html">wgetch(3x)</A></STRONG>.
66
67        <STRONG>o</STRONG>   The input is a printable character.   Printable  characters  (which
68            must  be  positive,  less  than  256)  are checked according to the
69            program's locale settings.
70
71        <STRONG>o</STRONG>   The input is the KEY_MOUSE special key  associated  with  an  mouse
72            event.
73
74        The menu driver requests are as follows:
75
76        REQ_LEFT_ITEM
77             Move left to an item.
78
79        REQ_RIGHT_ITEM
80             Move right to an item.
81
82        REQ_UP_ITEM
83             Move up to an item.
84
85        REQ_DOWN_ITEM
86             Move down to an item.
87
88        REQ_SCR_ULINE
89             Scroll up a line.
90
91        REQ_SCR_DLINE
92             Scroll down a line.
93
94        REQ_SCR_DPAGE
95             Scroll down a page.
96
97        REQ_SCR_UPAGE
98             Scroll up a page.
99
100        REQ_FIRST_ITEM
101             Move to the first item.
102
103        REQ_LAST_ITEM
104             Move to the last item.
105
106        REQ_NEXT_ITEM
107             Move to the next item.
108
109        REQ_PREV_ITEM
110             Move to the previous item.
111
112        REQ_TOGGLE_ITEM
113             Select/deselect an item.
114
115        REQ_CLEAR_PATTERN
116             Clear the menu pattern buffer.
117
118        REQ_BACK_PATTERN
119             Delete the previous character from the pattern buffer.
120
121        REQ_NEXT_MATCH
122             Move to the next item matching the pattern match.
123
124        REQ_PREV_MATCH
125             Move to the previous item matching the pattern match.
126
127        If the second argument is a printable character, the code appends it to
128        the pattern buffer and attempts to move to the next item  matching  the
129        new pattern.  If there is no such match, <STRONG>menu_driver</STRONG> returns <STRONG>E_NO_MATCH</STRONG>
130        and deletes the appended character from the buffer.
131
132        If the second argument is one of the above  pre-defined  requests,  the
133        corresponding action is performed.
134
135
136 </PRE><H3><a name="h3-MOUSE-HANDLING">MOUSE HANDLING</a></H3><PRE>
137        If  the  second  argument  is the KEY_MOUSE special key, the associated
138        mouse event is translated into one of the above  pre-defined  requests.
139        Currently only clicks in the user window (e.g., inside the menu display
140        area or the decoration window) are handled.
141
142        If you click above the display region of the menu:
143
144        <STRONG>o</STRONG>   a REQ_SCR_ULINE is generated for a single click,
145
146        <STRONG>o</STRONG>   a REQ_SCR_UPAGE is generated for a double-click and
147
148        <STRONG>o</STRONG>   a REQ_FIRST_ITEM is generated for a triple-click.
149
150        If you click below the display region of the menu:
151
152        <STRONG>o</STRONG>   a REQ_SCR_DLINE is generated for a single click,
153
154        <STRONG>o</STRONG>   a REQ_SCR_DPAGE is generated for a double-click and
155
156        <STRONG>o</STRONG>   a REQ_LAST_ITEM is generated for a triple-click.
157
158        If you click at an item inside the display area of the menu:
159
160        <STRONG>o</STRONG>   the menu cursor is positioned to that item.
161
162        <STRONG>o</STRONG>   If you double-click an item  a  REQ_TOGGLE_ITEM  is  generated  and
163            <STRONG>E_UNKNOWN_COMMAND</STRONG>  is  returned.   This  return  value makes sense,
164            because a double click usually means that an  item-specific  action
165            should be returned.  It is exactly the purpose of this return value
166            to signal that an application specific command should be executed.
167
168        <STRONG>o</STRONG>   If a translation into a request was done, <STRONG>menu_driver</STRONG>  returns  the
169            result of this request.
170
171        If  you clicked outside the user window or the mouse event could not be
172        translated into a menu request an <STRONG>E_REQUEST_DENIED</STRONG> is returned.
173
174
175 </PRE><H3><a name="h3-APPLICATION-DEFINED-COMMANDS">APPLICATION-DEFINED COMMANDS</a></H3><PRE>
176        If the second argument is neither printable nor one of the  above  pre-
177        defined  menu  requests  or  KEY_MOUSE,  the  drive  assumes  it  is an
178        application-specific    command    and    returns    <STRONG>E_UNKNOWN_COMMAND</STRONG>.
179        Application-defined commands should be defined relative to <STRONG>MAX_COMMAND</STRONG>,
180        the maximum value of these pre-defined requests.
181
182
183 </PRE><H2><a name="h2-RETURN-VALUE">RETURN VALUE</a></H2><PRE>
184        <STRONG>menu_driver</STRONG> return one of the following error codes:
185
186        <STRONG>E_OK</STRONG> The routine succeeded.
187
188        <STRONG>E_SYSTEM_ERROR</STRONG>
189             System error occurred (see <STRONG>errno(3)</STRONG>).
190
191        <STRONG>E_BAD_ARGUMENT</STRONG>
192             Routine detected an incorrect or out-of-range argument.
193
194        <STRONG>E_BAD_STATE</STRONG>
195             Routine was called from an initialization or termination function.
196
197        <STRONG>E_NOT_POSTED</STRONG>
198             The menu has not been posted.
199
200        <STRONG>E_UNKNOWN_COMMAND</STRONG>
201             The menu driver code saw an unknown request code.
202
203        <STRONG>E_NO_MATCH</STRONG>
204             Character failed to match.
205
206        <STRONG>E_REQUEST_DENIED</STRONG>
207             The menu driver could not process the request.
208
209
210 </PRE><H2><a name="h2-SEE-ALSO">SEE ALSO</a></H2><PRE>
211        <STRONG><A HREF="ncurses.3x.html">curses(3x)</A></STRONG>, <STRONG><A HREF="curs_getch.3x.html">getch(3x)</A></STRONG>, <STRONG><A HREF="menu.3x.html">menu(3x)</A></STRONG>.
212
213
214 </PRE><H2><a name="h2-NOTES">NOTES</a></H2><PRE>
215        The header  file  <STRONG>&lt;menu.h&gt;</STRONG>  automatically  includes  the  header  files
216        <STRONG>&lt;curses.h&gt;</STRONG>.
217
218
219 </PRE><H2><a name="h2-PORTABILITY">PORTABILITY</a></H2><PRE>
220        These  routines  emulate  the  System  V  menu  library.  They were not
221        supported on Version 7 or BSD versions.  The support for  mouse  events
222        is ncurses specific.
223
224
225 </PRE><H2><a name="h2-AUTHORS">AUTHORS</a></H2><PRE>
226        Juergen Pfeifer.  Manual pages and adaptation for new curses by Eric S.
227        Raymond.
228
229
230
231                                                                <STRONG><A HREF="menu_driver.3x.html">menu_driver(3x)</A></STRONG>
232 </PRE>
233 <div class="nav">
234 <ul>
235 <li><a href="#h2-NAME">NAME</a></li>
236 <li><a href="#h2-SYNOPSIS">SYNOPSIS</a></li>
237 <li><a href="#h2-DESCRIPTION">DESCRIPTION</a>
238 <ul>
239 <li><a href="#h3-MOUSE-HANDLING">MOUSE HANDLING</a></li>
240 <li><a href="#h3-APPLICATION-DEFINED-COMMANDS">APPLICATION-DEFINED COMMANDS</a></li>
241 </ul>
242 </li>
243 <li><a href="#h2-RETURN-VALUE">RETURN VALUE</a></li>
244 <li><a href="#h2-SEE-ALSO">SEE ALSO</a></li>
245 <li><a href="#h2-NOTES">NOTES</a></li>
246 <li><a href="#h2-PORTABILITY">PORTABILITY</a></li>
247 <li><a href="#h2-AUTHORS">AUTHORS</a></li>
248 </ul>
249 </div>
250 </BODY>
251 </HTML>