Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!ucsd!ucbvax!osf.org!meeks From: meeks@osf.org (W. Scott Meeks) Newsgroups: comp.windows.x.motif Subject: Re: Getting Selection in List Message-ID: <9012202055.AA15301@osf.osf.org> Date: 20 Dec 90 20:54:57 GMT References: <1990Dec19.215411.438@sctc.com> Sender: daemon@ucbvax.BERKELEY.EDU Distribution: inet Organization: The Internet Lines: 47 >From: swrinde!zaphod.mps.ohio-state.edu!sdd.hp.com!spool2.mu.edu!news.cs.indiana.edu!msi.umn.edu!sctc.com!thomsen@ucsd.edu (Dan Thomsen) > >How can I get a list of the items that are currently in a List widget? >I can use XtGetValues to find the number of items, but I can't get >the List out. Most likely I am not setting up the space for the >list correctly. Has anyone done this, and could they mail me a code >fragment? > This works for me: XmListWidget List1; register int n; Arg args[MAX_ARGS]; XmStringTable ItemTab; int count; n = 0; XtSetArg(args[n], XmNitems, &ItemTab); n++; XtSetArg(args[n], XmNitemCount, &count); n++; XtGetValues(List1, args, n); Now you can pull the items out of ItemTab and manipulate them however you like. Just don't free these strings or the table. For example: for (n = 0; n < count; n++) if (XmStringCompare(ItemTab[n], teststr) { result = XmStringGetLtoR(ItemTab[n], XmSTRING_DEFAULT_CHARSET, &str); if (result) { printf("Found: %s\n", str); } else { printf ("Couldn't get string for n = %d\n", n); } } Hope this helps. If you have any more questions, please ask. W. Scott Meeks Open Software Foundation meeks@osf.org (617) 621-7229