aboutsummaryrefslogtreecommitdiffstats
path: root/src/menu.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/menu.c')
-rw-r--r--src/menu.c96
1 files changed, 51 insertions, 45 deletions
diff --git a/src/menu.c b/src/menu.c
index d569b4b29b5..b40c2c04ce7 100644
--- a/src/menu.c
+++ b/src/menu.c
@@ -1112,51 +1112,8 @@ into menu items. */)
1112 return Qnil; 1112 return Qnil;
1113} 1113}
1114 1114
1115 1115Lisp_Object
1116DEFUN ("x-popup-menu", Fx_popup_menu, Sx_popup_menu, 2, 2, 0, 1116x_popup_menu_1 (Lisp_Object position, Lisp_Object menu)
1117 doc: /* Pop up a deck-of-cards menu and return user's selection.
1118POSITION is a position specification. This is either a mouse button event
1119or a list ((XOFFSET YOFFSET) WINDOW)
1120where XOFFSET and YOFFSET are positions in pixels from the top left
1121corner of WINDOW. (WINDOW may be a window or a frame object.)
1122This controls the position of the top left of the menu as a whole.
1123If POSITION is t, it means to use the current mouse position.
1124
1125MENU is a specifier for a menu. For the simplest case, MENU is a keymap.
1126The menu items come from key bindings that have a menu string as well as
1127a definition; actually, the "definition" in such a key binding looks like
1128\(STRING . REAL-DEFINITION). To give the menu a title, put a string into
1129the keymap as a top-level element.
1130
1131If REAL-DEFINITION is nil, that puts a nonselectable string in the menu.
1132Otherwise, REAL-DEFINITION should be a valid key binding definition.
1133
1134You can also use a list of keymaps as MENU.
1135 Then each keymap makes a separate pane.
1136
1137When MENU is a keymap or a list of keymaps, the return value is the
1138list of events corresponding to the user's choice. Note that
1139`x-popup-menu' does not actually execute the command bound to that
1140sequence of events.
1141
1142Alternatively, you can specify a menu of multiple panes
1143 with a list of the form (TITLE PANE1 PANE2...),
1144where each pane is a list of form (TITLE ITEM1 ITEM2...).
1145Each ITEM is normally a cons cell (STRING . VALUE);
1146but a string can appear as an item--that makes a nonselectable line
1147in the menu.
1148With this form of menu, the return value is VALUE from the chosen item.
1149
1150If POSITION is nil, don't display the menu at all, just precalculate the
1151cached information about equivalent key sequences.
1152
1153If the user gets rid of the menu without making a valid choice, for
1154instance by clicking the mouse away from a valid choice or by typing
1155keyboard input, then this normally results in a quit and
1156`x-popup-menu' does not return. But if POSITION is a mouse button
1157event (indicating that the user invoked the menu with the mouse) then
1158no quit occurs and `x-popup-menu' returns nil. */)
1159 (Lisp_Object position, Lisp_Object menu)
1160{ 1117{
1161 Lisp_Object keymap, tem, tem2; 1118 Lisp_Object keymap, tem, tem2;
1162 int xpos = 0, ypos = 0; 1119 int xpos = 0, ypos = 0;
@@ -1443,6 +1400,55 @@ no quit occurs and `x-popup-menu' returns nil. */)
1443 return selection; 1400 return selection;
1444} 1401}
1445 1402
1403DEFUN ("x-popup-menu", Fx_popup_menu, Sx_popup_menu, 2, 2, 0,
1404 doc: /* Pop up a deck-of-cards menu and return user's selection.
1405POSITION is a position specification. This is either a mouse button event
1406or a list ((XOFFSET YOFFSET) WINDOW)
1407where XOFFSET and YOFFSET are positions in pixels from the top left
1408corner of WINDOW. (WINDOW may be a window or a frame object.)
1409This controls the position of the top left of the menu as a whole.
1410If POSITION is t, it means to use the current mouse position.
1411
1412MENU is a specifier for a menu. For the simplest case, MENU is a keymap.
1413The menu items come from key bindings that have a menu string as well as
1414a definition; actually, the "definition" in such a key binding looks like
1415\(STRING . REAL-DEFINITION). To give the menu a title, put a string into
1416the keymap as a top-level element.
1417
1418If REAL-DEFINITION is nil, that puts a nonselectable string in the menu.
1419Otherwise, REAL-DEFINITION should be a valid key binding definition.
1420
1421You can also use a list of keymaps as MENU.
1422 Then each keymap makes a separate pane.
1423
1424When MENU is a keymap or a list of keymaps, the return value is the
1425list of events corresponding to the user's choice. Note that
1426`x-popup-menu' does not actually execute the command bound to that
1427sequence of events.
1428
1429Alternatively, you can specify a menu of multiple panes
1430 with a list of the form (TITLE PANE1 PANE2...),
1431where each pane is a list of form (TITLE ITEM1 ITEM2...).
1432Each ITEM is normally a cons cell (STRING . VALUE);
1433but a string can appear as an item--that makes a nonselectable line
1434in the menu.
1435With this form of menu, the return value is VALUE from the chosen item.
1436
1437If POSITION is nil, don't display the menu at all, just precalculate the
1438cached information about equivalent key sequences.
1439
1440If the user gets rid of the menu without making a valid choice, for
1441instance by clicking the mouse away from a valid choice or by typing
1442keyboard input, then this normally results in a quit and
1443`x-popup-menu' does not return. But if POSITION is a mouse button
1444event (indicating that the user invoked the menu with the mouse) then
1445no quit occurs and `x-popup-menu' returns nil. */)
1446 (Lisp_Object position, Lisp_Object menu)
1447{
1448 init_raw_keybuf_count ();
1449 return x_popup_menu_1 (position, menu);
1450}
1451
1446/* If F's terminal is not capable of displaying a popup dialog, 1452/* If F's terminal is not capable of displaying a popup dialog,
1447 emulate it with a menu. */ 1453 emulate it with a menu. */
1448 1454