Vol 6A pg 735-736 Section 21.1.2 Context-sensitive Help
- code sample declares:
XEvent *event;
and then calls XmTrackingEvent( toplevel, cursor, True, &event);
but XmTrackingEvent doesn't take a _XEvent** ... it takes a _XEvent*
Am I doing something wrong? Help. I'm using a SUN sparc compiler 4.2
-------
sent in by - Anthony Taiani:
The following are comments/suggestion regarding a particular
section of the Motif Programming Manual.
In Example 7-2, The modify_btn.c program, Pages 225-229,
regarding the setting of the XmNuserData resource in the
PromptDialog widget, programmatically, when the user selects either
of the buttons in the ToggleBox, the XmNuserData resource is set
ultimately through the functionality of XmVaCreateSimpleRadioBox.
In the Motif Reference Manual, Page 566, in the description of XmVaCreateSimpleRadioBox, it states
-----------------------------------------------------------------------------------
When the callback is invoked, the button number of the button whose value has changed is passed to the callback in the client_data
parameter.
-----------------------------------------------------------------------------------
The client data parameter of toggle_callback, through the functionality of XmVaCreateSimpleRadioBox, holds the selected toggle value which is
ultimately stored in the XmNuserData resource. But this fact is not offered in any part of the explanation of the setting of the XmNuserData resource
in Example 7.2 .
In the initial comment of the pushed function, it states
/* pushed() --the callback routine for the main app's pushbuttons.
** Create a dialog that prompts for a new button name or color.
** A RadioBox is attached to the dialog. Which button is selected
** in this box is held as an int (0 or 1) in the XmNuserData resource
** of the dialog itself. This value is changed when selecting either
** of the buttons in the ToggleBox and is queried in the dialog's
** XmNokCallback function.
*/
I would change this to
/* pushed() --the callback routine for the main app's pushbuttons.
** Create a dialog that prompts for a new button name or color.
** A RadioBox is attached to the dialog. Which button is selected
** in this box is held as an int (0 or 1) in the client data
** parameter of toggle_callback() through the functionality of
** XmVaCreateSimpleRadioBox(), and later stored in the
** XmNuserData resource of the dialog itself. The XmNuserData
** resource is changed when selecting either of the buttons in the
** ToggleBox, and is queried in the dialog's XmNokCallback function.
*/
In a comment of the pushed function, it states
-----------------------------------------------------------------------------------
/* Create the dialog -- the PushButton acts as the DialogShell's
** parent (not the parent of the PromptDialog). The "userData"
** is used to store the value
*/
-----------------------------------------------------------------------------------
I would change this to
-----------------------------------------------------------------------------------
/* Create the dialog -- the PushButton acts as the DialogShell's
** parent (not the parent of the PromptDialog). XmNuserData
** is used to globally store the toggle buttons value. Initialize
** XmNuserData to a 0 value corresponding to the
** radio_box initialization of 0 later in the code.
*/
-----------------------------------------------------------------------------------
I would add the comment regarding XmNuserData initialization
because XtSetArg (args[n], XmNuserData, 0);
initializes XmNuserData to the initial value of 0
corresponding to the initial toggle value of 0 for the
radio box defined in the code
toggle_box = XmVaCreateSimpleRadioBox (dialog,
"radio_box", 0, toggle_callback, .
In fact, in a previous edition of Motif Programming Manual (July 1992),
this code included an informative comment.
toggle_box = XmVaCreateSimpleRadioBox (dialog,
"radio_box", 0 /* initial value */, toggle_callback, .
I would reintroduce and expand the /* initial value */ comment in the code to
toggle_box = XmVaCreateSimpleRadioBox (dialog,
"radio_box", 0 /* initial toggle value */, toggle_callback, .
In a later section of the pushed function, it states
-----------------------------------------------------------------------------------
/* Create a toggle box -- callback routine is toggle_callback() */
btn1 = XmStringCreateLocalized ("Change Name");
btn2 = XmStringCreateLocalized ("Change Color");
toggle_box = XmVaCreateSimpleRadioBox (dialog,
"radio_box", 0, toggle_callback,
XmVaRADIOBUTTON, btn1, 0, NULL, NULL,
XmVaRADIOBUTTON, btn2, 0, NULL, NULL,
NULL);
-----------------------------------------------------------------------------------
I would extend the comment in this section of code to include a comment regarding the functionality of XmVaCreateSimpleRadioBox storing the button number of the button, whose value has changed, in the client data parameter of the callback function.
-----------------------------------------------------------------------------------
/* Create a toggle box -- callback routine is toggle_callback().
** XmVaCreateSimpleRadioBox() stores the button number of the
** toggle button, whose value has changed, in the client data
** parameter of the toggle_callback() callback function.
*/
btn1 = XmStringCreateLocalized ("Change Name");
btn2 = XmStringCreateLocalized ("Change Color");
toggle_box = XmVaCreateSimpleRadioBox (dialog,
"radio_box", 0 /* initial toggle value */, toggle_callback,
XmVaRADIOBUTTON, btn1, 0, NULL, NULL,
XmVaRADIOBUTTON, btn2, 0, NULL, NULL,
NULL);
-----------------------------------------------------------------------------------
In the comment of the toggle_callback function, it states
-----------------------------------------------------------------------------------
/* callback for the items in the toggle box -- the "client data" i
** the item number selected. Since the function gets called whenever
-----------------------------------------------------------------------------------
I would change this to
-----------------------------------------------------------------------------------
/* callback for the items in the toggle box -- the "client data" is
** the item number selected. The selected value is stored in the
** "client data" parameter of toggle_callback() through the functionality
** of XmVaCreateSimpleRadioBox(). Since the function gets called
** whenever
-----------------------------------------------------------------------------------
Later, in the description of the functionality of the XmNuserData resource,
it states
-----------------------------------------------------------------------------------
We add a RadioBox as the work area child of the PromptDialog. The ToggleButtons in the RadioBox indicate whether the input text is supposed to change the label of the PushButton or its text color. To determine which of these attributes to change, we use the callback routine toggle_callback().
Rather than storing the state of the RadioBox in a global variable, we store the value in the XmNuserData resource of the dialog widget. Using this technique, we can retrieve the value any time we
-----------------------------------------------------------------------------------
I would change this to
-----------------------------------------------------------------------------------
We add a RadioBox as the work area child of the PromptDialog. The ToggleButtons in the RadioBox indicate whether the input text is supposed to change the label of the PushButton or its text color. To determine which of these attributes to change, we use the callback routine toggle_callback().
Toggle_callback(), through the functionality of XmVaCreateSimpleRadioBox(), holds the state of the RadioBox in its client data parameter. Rather than storing the state of the RadioBox in a global variable, toggle_callback() stores the value in the XmNuserData resource of the dialog widget. Using this technique, we can retrieve the value any time we
-----------------------------------------------------------------------------------