[comp.windows.x] question: XToolkit - callbacks

stumpf@lan.informatik.tu-muenchen.dbp.de (Maex) (06/15/89)

Hello, it's me again!

This time I have a problem on callbacks!

Currently I'm creating a "confirm" widget, which looks like this:

	+-------------------------------+
	|                               |
	|         (any message)         |
	|                               |
	|     +-------+   +-------+     |
	|     | butt1 |   | butt2 |     |
	|     +-------+   +-------+     |
	|                               |
	+-------------------------------+

(any message) is a labelWidget
butt1, butt2  are commandWidgets

My widget supports XtNcallback.
I have a callback routine ButtonPress() which I add to the
callback list of butt1 and butt2 and which gets in the client_data
0 or 1, depending on which button was clicked. This value (o or 1)
I'd like to put in the  client_data field of "my" callback.

My problem is, that when ButtonPress() is called, I only get the
WidgetId of the commandWidget the button was pressed in, but not
the WidgetId of "my" widget.
Currently ButtonPress looks like this:

static void ButtonPress(w, cl_data, ca_data)
   Widget	w;
   caddr_t	cl_data, ca_data;
{
	XtCallCallbacks(XtParent(w), XtNcallback, cl_data);
}

Is this correct, or is there a better solution, to call "my" callback
list. (The above works correctly for me, but I don't know, whether this
is good behaviour)

Thanks
	\Maex

+------------------------------------------------------------------------------+
|  Markus Stumpf                                                               |
|  TU Muenchen                        local: lan.informatik.tu-muenchen.dbp.de |
|  Inst. f. Informatik                  DFN: stumpf@{local}                    |
|  Arcisstrasse                        UUCP: stumpf%{local}@unido.uucp         |
|  D-8000 Muenchen                  ARPA/CS: stumpf%{local}@relay.cs.net       |
|  West Germany                      BITNET: infrza02@dm0tui1s.bitnet          |
+------------------------------------------------------------------------------+
+------------------------------------------------------------------------------+
|  Markus Stumpf                                                               |
|  TU Muenchen                        local: lan.informatik.tu-muenchen.dbp.de |
|  Inst. f. Informatik                  DFN: stumpf@{local}                    |

swick@ATHENA.MIT.EDU (Ralph R. Swick) (06/16/89)

> static void ButtonPress(w, cl_data, ca_data)
>    Widget	w;
>    caddr_t	cl_data, ca_data;
> {
> 	XtCallCallbacks(XtParent(w), XtNcallback, cl_data);
> }
> 
> Is this correct, or is there a better solution, to call "my" callback
> list.

I don't think you can do any better than this and still hide the
implementation of 'mywidget'.