Path: utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!snorkelwacker!tut.cis.ohio-state.edu!ucbvax!bloom-beacon!athena.mit.edu!bjaspan From: bjaspan@athena.mit.edu (Barr3y Jaspan) Newsgroups: comp.windows.x Subject: Re: Getting ID for widget loaded from .uid? (Motif) Message-ID: <1990Jan10.172318.20172@athena.mit.edu> Date: 10 Jan 90 17:23:18 GMT References: <223@uucs1.UUCP> Sender: news@athena.mit.edu (News system) Reply-To: bjaspan@athena.mit.edu (Barr3y Jaspan) Organization: Massachusetts Institute of Technology Lines: 34 In article <223@uucs1.UUCP>, gaf@uucs1.UUCP (gaf) writes: > > I can't believe there isn't a simple, approved way to do this, but can't > see one for the life of me. > > I fetch a tree of widgets from my .uid file, and need the widget ID of > some of them so I can twiddle their resources on the fly. Trouble is, > I can't see a way of finding the widget ID. Yes, you are missing something obvious. In fact, there are two perfectly good ways to do what you want. 1) XtNameToWidget() 2) callbacks. 1) XtNameToWidget takes a widget and a list of names of children and returns the widget ID of the last child in the list. For example, suppose you have the widget tree foo bar baz quux Then XtNameToWidget(foo, "bar.quux") would return the ID of "quux." Presumably the ID of "foo" comes from MrmFetchHierarchy(). I seem to recall there being a problem with using this with popup windows or menus or something, but I don't recall the exact details -- I think you just have to be very careful to get all the intermediate children widget names correct. 2) callbacks. All motif widgets have a "create" callback, and all callbacks are passed the widget ID of the widget that caused them to happen. Thus, you can specify a create callback and have each widget pass it a unique client_data parameter, and save away the widget ID. Barry Jaspan, MIT-Project Athena bjaspan@athena.mit.edu