* menu_item's sensitivity is reset.
*/
XtAddCallback (XtParent(dialog), /* dialog's _parent_ */
XmNpopdownCallback, reset_sensitive, menu_item);
XtAddCallback (dialog, XmNdestroyCallback, reset_sensitive, menu_item);
XtManageChild (dialog);
XtPopup (XtParent (dialog), XtGrabNone);
}
The open_callback() function is called whenever the user activates the Open menu item on the File menu. The
first thing open_callback() does is find the nearest WMShell widget associated with the menu item. We do not
want the MenuShell here, as we need a non−transient widget to act as the parent for the FileSelectionDialog. If the
menu item is used as the parent for the dialog, when the menu is popped down, the dialog is also popped down
because it is a secondary window.
We set the menu item's sensitivity to False, which prevents the user from selecting the item again. In order to be
notified when the FileSelectionDialog is dismissed, we add callback routines for XmNpopdownCallback and
XmNdestroyCallback. In both cases, the Open menu item needs to be reset so that the user can select it again.
The only thing in open_callback() is a callback function that opens the selected file when the user selects the
OK button. This functionality is beyond the scope of this chapter; see Chapter 6, Selection Dialogs, for details.
16.3.7 Tear−Off Menus
Motif 1.2 provides a new feature that allows menus to be torn off and placed in separate windows. From the user's
perspective, tear−off menus make it easy to make repeated menu ...