The routine tests the callback structure's reason field to determine whether the callback was invoked as a result of a
multiple selection action or the default action. When the reason is XmCR_MULTIPLE_SELECT, we print the list of
selected items by looping through selected_items and selected_item_positions. With this reason, all
of the fields in the callback structure except selection_type are valid. If the reason is
XmCR_DEFAULT_ACTION, there is only one item selected, since the default selection action causes all of the other
items to be deselected.
13.5.4 Extended Selection Callback
With the extended selection model, the user has the greatest flexibility to select and deselect individual items or ranges
of items. The XmNextendedSelectionCallback is invoked whenever the user makes a selection or modifies
the selection. the source code demonstrates the sel_callback() routine that could be used with an extended
selection List. XmFONTLIST_DEFAULT_TAG replaces XmSTRING_DEFAULT_CHARSET in Motif 1.2.
void
sel_callback(list_w, client_data, call_data)
Widget list_w;
XtPointer client_data;
XtPointer call_data;
{
XmListCallbackStruct *cbs = (XmListCallbackStruct *) call_data;
char *choice;
int i;
if (cbs−>reason == XmCR_EXTENDED_SELECT) {
if (cbs−>selection_type == XmINITIAL)
printf ("Extended selection −− initial selection: ");
else if (cbs−>selection_type == XmMODIFICATION)
printf ("Extended selction −− modification of selection: ");
else /* selection type = XmADDITION */
printf ("Extended selection ...