D.9.0.2 The menu attributes for menu accelerators
The following attributes provide functionality to define menu accelerators for menu items.
The basic difference for menu accelerators is that when an accelerator (eg. Meta+l) is
pressed, the menu is not brought up. Instead, the procedures that are normally called when
one selects a menu item, are called directly.
Each new attribute below corresponds to one of many ways of creating a menu item. The
attribute MENU_STRINGS_AND_ACCELERATORS and MENU_ACTION_ACCELERATOR are for
static creation of menu items for a given menu.
The attribute MENU_ACCELERATOR, when used in a create or set call, set an accelerator on a
menu item:
Menu menu;
menu = xv_create(NULL, MENU
MENU_ITEM,
MENU_STRING, "Load",
MENU_NOTIFY_PROC, load_proc,
MENU_ACCELERATOR, "Meta+l",
NULL,
NULL);
or
Menu_item load_item;
load_item = xv_create(NULL, MENU_ITEM,
MENU_STRING, "Load",
MENU_NOTIFY_PROC, load_proc,
MENU_ACCELERATOR, "Meta+l",
NULL);
The accelerator string will be copied by XView. A get returns the accelerator string. The
string returned should not be modified.
The attribute MENU_ACTION_ACCELERATOR can be used to create a menu item with a given
label, notify procedure, and accelerator:
xv_set(menu,
MENU_ACTION_ACCELERATOR,
"Load", load_proc, "Meta+L",
NULL);
The menu item label string, the first argument, will not be copied by XView. The accelerator
string, argument three, will be copied.
MENU_STRINGS_AND_ACCELERATORS can be used to create a menu item with a given label
and accelerator:
xv_set(menu, MENU_NOTIFY_PROC, file_proc,
MENU_STRINGS_AND_ACCELERATORS,
"Load", "Meta+l",
"Print", "Meta+p",
"Include","Meta+Ctrl+i",
NULL,
NULL);
Version 3.2 and
the File Chooser
Version 3.2 and the File Chooser 697
The accelerator strings will be copied by XView. The menu item label strings will not be
copied.
For all the attributes above, if an accelerator is changed with xv_set, the attribute
FRAME_MENUS must be set again before the change to the accelerator will take effect.
Callback procedures registered using MENU_NOTIFY_PROC, MENU_GEN_PROC, and
MENU_DONE_PROC will be called the same way for menu accelerators as if the menu item was
selected using the menu directly.
The accelerators can be specified in a number of ways. These specifications are a combina-
tion of Xt, OLIT, and XView syntaxes:
Xt: [modifier...] <Key>key
OLIT: [OLITmodifier...] <key>
XView: [modifier [’+ modifier] +] key
modifier: Meta | Shift | Alt | Hyper | Ctrl |
OLITmodifier: modifier | m | s | a | h | c
Key: all print characters and X keysym names (e.g. ’return’, ’tab’, ’comma’, ’period’,
etc . . . )
Note: keysym names consist of the entries in <X11/keysymdef.h> without the “XK_” prefix.
For example:
Meta+Shift+a
Meta+comma
Meta <Key>c
Shift Meta <Key>I
m <z>
D.9.0.3 Resources
The resource <appname>.<menu item instance name>.accelerator can be used to override the
accelerator specified using the attributes described above.
For example, in the application ’foo’, if we have:
load_item = xv_create(NULL, MENUITEM,
XV_INSTANCE_NAME, "load",
MENU_STRING, "load",
MENU_ACCELERATOR, "Meta+l",
MENU_NOTIFY_PROC, load_action,
NULL);
The "Meta+l” can be overriden by having the following entry in your X resource database:
foo.load.accelerator:Meta+b
The load action will be done when “Meta+b” is pressed instead of “Meta+l”. Note:
XV_INSTANCE_NAME will need to be used to give the menu item an instance name.
698 Version 3.2 and the File Chooser
D.9.0.4 Core set menu accelerators
Various menu accelerators for “common features” of OpenWindows (e.g. Print, Save, Quit,
Undo, Paste, etc.) are called the core set menu accelerators. These accelerators are special in
that they are specified using the string: "coreset <core set name>" instead of the
syntax mentioned above. For example:
load_item = xv_create(NULL, MENUITEM,
MENU_STRING, "Open",
MENU_ACCELERATOR, "coreset Open",
MENU_NOTIFY_PROC, load_action,
NULL);
The core set menu accelerators will be activated only if the X resources:
OpenWindows.MenuAccelerator.<core set name>:<accelerator string>
are present. For example:
OpenWindows.MenuAccelerator.Open:Meta<key>o
This means that the key combination meta-o is the menu accelerator for the “open” action.
These resources can also be used to rebind the core set accelerators. The advantage of core
set accelerators is that all applications that use them will have uniform accelerators (use the
same key bindings for the same functions). Rebinding using the resource above will affect all
such applications.
The list of possible values of <core set name> and the default case-sensitive resource bind-
ings for OpenWindows.MenuAccelerator.<core set name> are as follows:
Core set accelerator Default binding
BoldFont Shift Meta <Key>B
Copy Meta<Key>c
Cut Meta <Key>x
Find Meta <Key>f
ItalicFont Shift Meta <Key>I
New Meta <Key>n
NormalFont Shift Meta <Key>N
Open Meta <Key>o
Paste Meta <Key>v
Print Meta <Key>p
Props Meta <Key>i
Redo Shift Meta <Key>Z
Save Meta <Key>s
SelectAll Meta <Key>a
Typeface Meta <Key>t
Undo Meta <Key>z
In OpenWindows 3.2, the above bindings are set by default upon startup.
Version 3.2 and
the File Chooser
Version 3.2 and the File Chooser 699
D.9.0.5 Events
When a menu is brought up using menu_show() and a menu item is selected, it is possible
to query the menu using the attribute MENU_FIRST_EVENT to obtain the event
(event_action(event) == ACTION_MENU) that was passed into menu_show(),
presumably the event that caused the menu to be brought up.
Event *menu_event;
menu_event = (Event *)xv_get(menu, MENU_FIRST_EVENT);
When a menu item notify procedure is called using a menu accelerator, MENU_FIRST_EVENT
will return the event corresponding to the accelerator. That is, the event that corresponds to
“Meta+l”. The action id, obtained using the event_action() macro, will be
ACTION_ACCELERATOR. The window id in the event will be the subwindow that had input
focus (and received the key event) at the time.
D.10 File Chooser and Version 3.2 Additions Summary
Table D-1 lists the procedures macros for the File Chooser. Table D-2 lists the attributes and
macros the File Chooser. This section also lists the attributes for the
HISTORY, FILE_LIST
and PATH packages, as well as the XView Version 3.2 and newer PANEL_LIST and MENU
accelerator additions. This information is described fully in the XView Reference Manual.
Table D-1. File Chooser Procedures and Macros
Procedures and Macros
fchsr_case_ascend_compare() FILE_CHOOSER_OPEN_DIALOG
fchsr_case_descend_compare() FILE_CHOOSER_SAVE_DIALOG
fchsr_no_case_ascend_compare() FILE_CHOOSER_SAVEAS_DIALOG
fchsr_no_case_descend_compare() FILE_CHOOSER_NULL_COMPARE
FILE_CHOOSER_DEFAULT_COMPARE
Table D-2. File Chooser Attributes
FILE_CHOOSER_ABBREV_VIEW FILE_CHOOSER_FILTER_MASK
FILE_CHOOSER_APP_DIR FILE_CHOOSER_FILTER_STRING
FILE_CHOOSER_AUTO_UPDATE FILE_CHOOSER_HISTORY_LIST
FILE_CHOOSER_CD_FUNC FILE_CHOOSER_MATCH_GLYPH
FILE_CHOOSER_CHILD FILE_CHOOSER_MATCH_GLYPH_MASK
FILE_CHOOSER_COMPARE_FUNC FILE_CHOOSER_NOTIFY_FUNC
FILE_CHOOSER_CUSTOMIZE_OPEN FILE_CHOOSER_NO_CONFIRM
FILE_CHOOSER_DIRECTORY FILE_CHOOSER_SAVE_TO_DIR
FILE_CHOOSER_DOC_NAME FILE_CHOOSER_SHOW_DOT_FILES
700 Version 3.2 and the File Chooser
Table D-2. File Chooser Attributes (continued)
FILE_CHOOSER_EXTEN_FUNC FILE_CHOOSER_TYPE
FILE_CHOOSER_EXTEN_HEIGHT FILE_CHOOSER_UPDATE
FILE_CHOOSER_FILTER_FUNC
Table D-3. History and History Menu Attributes
HISTORY_ADD_FIXED_ENTRY HISTORY_MENU_HISTORY_LIST
HISTORY_ADD_ROLLING_ENTRY HISTORY_MENU_OBJECT
HISTORY_DUPLICATE_LABELS HISTORY_NOTIFY_PROC
HISTORY_DUPLICATE_VALUES HISTORY_ROLLING_COUNT
HISTORY_FIXED_COUNT HISTORY_ROLLING_MAXIMUM
HISTORY_INACTIVE HISTORY_VALUE
HISTORY_LABEL
Table D-4. File List Attributes
FILE_LIST_ABBREV_VIEW FILE_LIST_MATCH_GLYPH
FILE_LIST_AUTO_UPDATE FILE_LIST_MATCH_GLYPH_MASK
FILE_LIST_CHANGE_DIR_FUNC FILE_LIST_ROW_TYPE
FILE_LIST_COMPARE_FUNC FILE_LIST_SHOW_DIR
FILE_LIST_DIRECTORY FILE_LIST_SHOW_DOT_FILES
FILE_LIST_DOTDOT_STRING FILE_LIST_UPDATE
FILE_LIST_FILTER_FUNC FILE_LIST_USE_FRAME
FILE_LIST_FILTER_MASK
FILE_LIST_FILTER_STRING
Table D-5. Path Attributes
PATH_IS_DIRECTORY
PATH_USE_FRAME
PATH_RELATIVE_TO
PATH_LAST_VALIDATED
Version 3.2 and
the File Chooser
Version 3.2 and the File Chooser 701

Get Volume 7A: XView Programming Manual now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.