X11 menu tweaks

Restore handling for keystrokes on PICK_NONE menus so that scrolling
via keys works for them.  (That handling was disabled as part of the
patch to support MENUCOLORS.)

Enable [cancel] button for all menus.  (That had apparently been
grayed out for PICK_NONE menus since day 1 for X11 windowing.)
This commit is contained in:
PatR
2018-10-27 19:26:56 -07:00
parent aa0b973001
commit d77ecd4ae5
3 changed files with 19 additions and 9 deletions

View File

@@ -1920,35 +1920,38 @@ char *input;
/* Display file ----------------------------------------------------------- */
/* uses a menu (with no selectors specified) rather than a text window
to allow previous_page and first_menu actions to move backwards */
void
X11_display_file(str, complain)
const char *str;
boolean complain;
{
dlb *fp;
winid newwin;
struct xwindow *wp;
anything any;
menu_item *menu_list;
#define LLEN 128
char line[LLEN];
/* Use the port-independent file opener to see if the file exists. */
fp = dlb_fopen(str, RDTMODE);
if (!fp) {
if (complain)
pline("Cannot open %s. Sorry.", str);
return; /* it doesn't exist, ignore */
}
winid newwin = X11_create_nhwindow(NHW_MENU);
struct xwindow *wp = &window_list[newwin];
anything any = zeroany;
menu_item *menu_list;
newwin = X11_create_nhwindow(NHW_MENU);
wp = &window_list[newwin];
X11_start_menu(newwin);
any = zeroany;
while (dlb_fgets(line, LLEN, fp)) {
X11_add_menu(newwin, NO_GLYPH, &any, 0, 0, ATR_NONE, line, MENU_UNSELECTED);
X11_add_menu(newwin, NO_GLYPH, &any, 0, 0, ATR_NONE,
line, MENU_UNSELECTED);
}
(void) dlb_fclose(fp);
/* show file name as the window title */

View File

@@ -254,7 +254,8 @@ Cardinal *num_params;
return;
}
if (menu_info->is_active && menu_info->how != PICK_NONE) { /* waiting for input */
/* don't exclude PICK_NONE menus; doing so disables scrolling via keys */
if (menu_info->is_active) { /* waiting for input */
/* first check for an explicit selector match, so that it won't be
overridden if it happens to duplicate a mapped menu command (':'
to look inside a container vs ':' to select via search string) */
@@ -324,12 +325,14 @@ Cardinal *num_params;
} else if (ch == MENU_FIRST_PAGE || ch == MENU_LAST_PAGE) {
Widget hbar = (Widget) 0, vbar = (Widget) 0;
float top = (ch == MENU_FIRST_PAGE) ? 0.0 : 1.0;
find_scrollbars(wp->w, &hbar, &vbar);
if (vbar)
XtCallCallbacks(vbar, XtNjumpProc, &top);
return;
} else if (ch == MENU_NEXT_PAGE || ch == MENU_PREVIOUS_PAGE) {
Widget hbar = (Widget) 0, vbar = (Widget) 0;
find_scrollbars(wp->w, &hbar, &vbar);
if (vbar) {
float shown, top;
@@ -1029,7 +1032,9 @@ Widget form,under;
num_args = 0;
XtSetArg(args[num_args], nhStr(XtNfromVert), label); num_args++;
XtSetArg(args[num_args], nhStr(XtNfromHoriz), ok); num_args++;
#if 0 /* [cancel] is a viable choice even for PICK_NONE */
XtSetArg(args[num_args], nhStr(XtNsensitive), how != PICK_NONE); num_args++;
#endif
XtSetArg(args[num_args], nhStr(XtNtop), XtChainTop); num_args++;
XtSetArg(args[num_args], nhStr(XtNbottom), XtChainTop); num_args++;
XtSetArg(args[num_args], nhStr(XtNleft), XtChainLeft); num_args++;