summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard M. Stallman <rms@gnu.org>1996-08-10 18:48:18 +0000
committerRichard M. Stallman <rms@gnu.org>1996-08-10 18:48:18 +0000
commitb5caf3774830399b0a7e31130d6362be4da43056 (patch)
treeac2420e05a0cc2d497a64c5c810fccc7e7ec7ad0
parentf7863171769dd275c05b13ddb6c15bf0a1bf2d28 (diff)
downloademacs-b5caf3774830399b0a7e31130d6362be4da43056.tar.gz
(update_one_menu_entry): When creating a pulldown
in an existing but empty menu item, in order to get a new functional pulldown, the menu item must be switched from an XmPushButtonGadget into a XmCascadeButtonGadget.
-rw-r--r--lwlib/lwlib-Xm.c39
1 files changed, 36 insertions, 3 deletions
diff --git a/lwlib/lwlib-Xm.c b/lwlib/lwlib-Xm.c
index c5da97f85ed..38713adb25f 100644
--- a/lwlib/lwlib-Xm.c
+++ b/lwlib/lwlib-Xm.c
@@ -509,11 +509,41 @@ update_one_menu_entry (instance, widget, val, deep_p)
{
if (contents)
{
- menu = XmCreatePulldownMenu (XtParent (widget), XtName (widget), NULL, 0);
+ unsigned int old_num_children, i;
+ Widget button, parent;
+ Widget *widget_list;
+ int buttonchange;
+
+ parent = XtParent (widget);
+ widget_list = XtCompositeChildren (parent, &old_num_children);
+
+ /* Find the widget position within the parent's widget list. */
+ for (i = 0; i < old_num_children; i++)
+ if (strcmp (XtName (widget_list[i]), XtName (widget)) == 0)
+ break;
+ if (i == old_num_children)
+ abort ();
+ /* `buttonchange' indicates the parent button is being
+ exchanged with a CascadeButton. */
+ buttonchange = !XmIsCascadeButton (widget_list[i]);
+ if (buttonchange)
+ XtDestroyWidget (widget_list[i]);
+ menu = XmCreatePulldownMenu (parent, val->name, NULL, 0);
make_menu_in_widget (instance, menu, contents, 0);
ac = 0;
XtSetArg (al [ac], XmNsubMenuId, menu); ac++;
- XtSetValues (widget, al, ac);
+ /* Non-zero values don't work reliably in
+ conjunction with Emacs' event loop */
+ XtSetArg (al [ac], XmNmappingDelay, 0); ac++;
+ /* Tell Motif to put it in the right place. */
+ XtSetArg (al [ac], XmNpositionIndex, i); ac++;
+ button = XmCreateCascadeButtonGadget (parent, val->name, al, ac);
+ xm_update_label (instance, button, val);
+
+ XtAddCallback (button, XmNcascadingCallback, xm_pull_down_callback,
+ (XtPointer)instance);
+ if (buttonchange)
+ XtManageChild (button);
}
}
else if (!contents)
@@ -575,7 +605,10 @@ xm_update_menu (instance, widget, val, deep_p)
for (i = 0, cur = val->contents; i < num_children_to_keep; i++)
{
if (!cur)
- abort ();
+ {
+ num_children_to_keep = i;
+ break;
+ }
if (children [i]->core.being_destroyed
|| strcmp (XtName (children [i]), cur->name))
continue;