[comp.windows.open-look] xview and xv_key_data

fgreco@govt.shearson.com (Frank Greco) (02/20/91)

The XVPM says (pg 170) that when you use XV_KEY_DATA, a *unique*
key is required.  How *unique* must this be?   Obviously,
keys must be at least unique when you attach more than one
key to a particular XView object.  But it seems like this is the only
restriction.

In some tests I've made, I've attached different chunks of 
data to three different objects (eg, textitems) all using the
same key.  It appears to work, but I'd like to be sure.

Must all keys, regardless of the type of object it is attached to,
be unique?

Since I'm attaching data to a whole slew of objects, I'd rather
not keep a separate data structure around just to hold object ptrs
and XV_KEY_DATA keys (and of course, you also need a proc to find 
a key given the obj ptr).


Thanks all,

Frank G.

cflatter@zia.AOC.NRAO.EDU (Chris Flatters) (02/21/91)

Frank Greco writes:
> The XVPM says (pg 170) that when you use XV_KEY_DATA, a *unique*
> key is required.  How *unique* must this be?   Obviously,
> keys must be at least unique when you attach more than one
> key to a particular XView object.  But it seems like this is the only
> restriction.
> ...
> Must all keys, regardless of the type of object it is attached to,
> be unique?

I'm sure that the key need only be unique within a particular XView object.
XView itself occasionally attaches data to an XV_KEY_DATA tag of 1 so that
disjoint parts of the package can find the data at a specific location.

		Chris Flatters

andrew@resam.dk (Leif Andrew Rump) (02/26/91)

In <4x8vhx3@openlook.Unify.Com> fgreco@govt.shearson.com (Frank Greco) writes:
>The XVPM says (pg 170) that when you use XV_KEY_DATA, a *unique*
>key is required.  How *unique* must this be?   Obviously,
>keys must be at least unique when you attach more than one
>key to a particular XView object.  But it seems like this is the only
>restriction.

Data may be attached to any XView object (frame, button, list, ...)
using an unique key which may be obtained by calling: xv_unique_key()
The data attached is local to that object i.e. the same unique key
may be used on different objects (the same unique key is usually
used to safe the same information in the relevant objects).

>In some tests I've made, I've attached different chunks of 
>data to three different objects (eg, textitems) all using the
>same key.  It appears to work, but I'd like to be sure.

You may attach different data to the same object as long as they
each have a unique key and the same key may be used on different
objects.

>Must all keys, regardless of the type of object it is attached to,
>be unique?

I could write my answer a third way but I think I've made it clear  :-)

>Since I'm attaching data to a whole slew of objects, I'd rather
>not keep a separate data structure around just to hold object ptrs
>and XV_KEY_DATA keys (and of course, you also need a proc to find 
>a key given the obj ptr).

Well XV_KEY_DATA is perfect for that!

Leif Andrew


Leif Andrew Rump, AmbraSoft A/S, Stroedamvej 50, DK-2100 Copenhagen OE, Denmark
UUCP: andrew@ambra.dk, phone: +45 39 27 11 77                /
Currently at Scandinavian Airline Systems                =======/
UUCP: andrew@resam.dk, phone: +45 32 32 51 54                \
SAS, RESAM Project Office, CPHML-V, P.O.BOX 150, DK-2770 Kastrup, Denmark

> > Read oe as: o <backspace> / (slash) and OE as O <backspace> / (slash) < <